findChildContext static method
Walks the children of this context.
Implementation
static BuildContext? findChildContext({
required BuildContext context,
required bool Function(Element) isTargetType,
}) {
BuildContext? childContext;
void visitor(Element element) {
if (isTargetType(element)) {
/// Find the target child BuildContext
childContext = element;
return;
}
element.visitChildren(visitor);
}
try {
// https://github.com/fluttercandies/flutter_scrollview_observer/issues/35
context.visitChildElements(visitor);
} catch (e) {
Log.warning(
'This widget has been unmounted, so the State no longer has a context (and should be considered defunct). \n'
'Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.',
);
}
return childContext;
}