September 2019
Beginner
512 pages
12h 52m
English
The Form widget comes with a helpful class to dispense with the need to add a key to it and still get its benefits.
Each Form widget in the tree has an associated InheritedWidget with it. Form and many other widgets expose this in a static method called of(), where we pass BuildContext, and it looks up the tree to find the corresponding State we are looking for. Knowing this, if we need to access the Form widget somewhere below it in the tree, we can use Form.of(), and we gain access to the same functions as we would have if we using the key property:
// part of input/main.dart example (full source code attached)// build() in InputFormInheritedStateExamplesWidget classForm( child: Column( mainAxisSize: MainAxisSize.min, ...
Read now
Unlock full access