Skip to content

Commit

Permalink
documenting :height :width :color :padding and :when
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrand committed Feb 25, 2024
1 parent 02b97c0 commit 95d5ca0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
8 changes: 7 additions & 1 deletion clj/src/cljd/flutter.cljd
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,13 @@
Out of the box it means: atoms, Streams, Futures, Listenables,
ValueListenable and... nil.
These bindings can take options (in the same way as :managed bindings do).
Supported options are :refresh-on, :dispose, :dedup and :>
Supported options are :as, :default, :refresh-on, :dispose, :dedup and :>
- :as -- gives a name to the watched resource (e.g. to be able to swap! on
it if it's an atom)
- :default -- provides an interim value to use while the first actual value
is available (e.g. while waiting for a Future to complete or a Stream to
produce a value). Useless when the watched resource can provide a current
value (atoms for example).
- :refresh-on expr -- see :managed
- :dispose form -- if the object under watch also needs to be managed use
this option. Works like :dispose for :managed except for \":dispose true\"
Expand Down
23 changes: 22 additions & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ Dynamic binding but along the widgets tree, not the call tree. Inherited binding
### `:get` directive
`:get [:k1 :k2]` retrieves values bound to `:k1` and `:k2` via `:bind` and binds these values to `k1` and `k2` in the lexical scope (the following forms).

`:get [m/Navigator]` retrieves instance returned by `(m/Navigator.of context)` and lexically binds it to `navigator` -- implicit kebab-casing of teh Dart name.
`:get [m/Navigator]` retrieves instance returned by `(m/Navigator.of context)` and lexically binds it to `navigator` -- implicit kebab-casing of teh Dart name.

### `:context` directive — when Flutter lacks context
`:context ctx` binds ctx to a `BuildContext` instance.
Expand All @@ -388,3 +388,24 @@ This comes handy when you have to pass a `BuildContext` to a Flutter call. Howev
### `:vsync` directive — chasing the electron beam across a phosphor screen

`:vsync clock` binds `clock` to a `TickerProvider`, generally required by animations.

### `:height`, `:width` and `:color`

Utilities directives to cut on SizedBox, ColoredBox or Container usage.

`:height` and `:width` expect a numeric value.

`:color` expects an instance of `Color` as value.

### `:padding`

Utility directive to simplify setting padding.

`:padding padding-expr` where `padding-expr` may evaluate to:
* an `EdgeInsetsGeometry` instance
* a number -- in which case it's passed to `EdgeInsets.all` to specify that it's the padding in all directions
* a map with keys amongst `:top` `:bottom` `:left` `:right` `:start` `:end` `:horizontal` `:vertical` (and numeric values)

### `:when`

`:when test` will show the rest of the widget only when test is truthy (not `nil` or `false`).

0 comments on commit 95d5ca0

Please sign in to comment.