visitStateOrNull<T extends State<StatefulWidget> > method
T?
visitStateOrNull<T extends State<StatefulWidget> >({})
Returns the first T with filter below this BuildContext, or null.
If last is true, then it will return the last State found.
Visiting last is O(N), avoid using last = true.
Implementation
T? visitStateOrNull<T extends State>({
bool last = false,
bool Function(T state)? filter,
}) {
bool filterByT(StatefulElement e) =>
e.state is T && (filter?.call(e.state as T) ?? true);
return visitElementOrNull(last: last, filter: filterByT)?.state as T?;
}