-
Notifications
You must be signed in to change notification settings - Fork 9
Configuring new Flutter constructors for FMX
Exposing a native Flutter widget in the Flutter/MX, or f/mx, API requires custom selection of the right f/mx "factory" macro for that widget. Examples from the f/mx core:
(deftag tiltontec.flutter-mx.factory/k1-param1-stateless text m/Text)
(deftag tiltontec.flutter-mx.factory/childless-stateful text-field m/TextField)
(deftag tiltontec.flutter-mx.factory/prop-param1-childless-stateful icon m/Icon :icon)
...etc...
So far we have a little over a dozen options. They vary by statefulness and how children/chid/content/body are handled. re the latter, we find the more uniform HTML approach, where nodes just have children, more effective at simplifying coding and reducing boilerplate.
In an extreme case, we allow one child for a scaffold and treat that as the body
. This decision is easily changed by simply coding up a new converter.
Speaking of coding up new converters, an open item on our roadmap is to expose all widgets ourselves, but for now using an unexposed widget requires an RFE on GitHub, or doing it yourself. Here is how I do it:
- check the Flutter spec for that class. Here is the link for Text.
- we see Text does not have a
child
, so we look at the constructor and see it takes the Text data as the first parameter. Here, by the way, is a case where HTML is more uniform and takes its content as a child; - next I look for "Inheritance". In this case:
**Inheritance**
Object > DiagnosticableTree > Widget > StatelessWidget > Text
So we want a stateless widget where the first child, in our uniform all-children-all-the-time scheme, becomes the first parameter to the Flutter constructor k1-param1-stateless
, with the desired f/mx constructor text
as the first parameter and m/Text
, the Flutter constructor, as the second parameter.
(deftag tiltontec.flutter-mx.factory/k1-param1-stateless text m/Text)
WIP: we will add discussion of trickier factories as we go. In the meantime, again, file an RFE or ping @kennytilton on the Clojurians or Flutter Community slacks.
.