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