of static method
Returns the nearest model up its widget tree
If listen
is true
(default value), all the dependents widgets
will rebuild each time the model change.
listen: false
is necessary if want to avoid rebuilding the
context
when model changes:
Implementation
static AbstractControl<Object>? of(BuildContext context,
{bool listen = true}) {
if (listen) {
return context
.dependOnInheritedWidgetOfExactType<FormControlInheritedStreamer>()
?.control;
}
final element = context.getElementForInheritedWidgetOfExactType<
FormControlInheritedStreamer>();
return element == null
? null
: (element.widget as FormControlInheritedStreamer).control;
}