findAncestorElementOfWidgetType<T extends Widget> static method
Implementation
static Element? findAncestorElementOfWidgetType<T extends Widget>(Element? element) {
if (element == null) {
return null;
}
Element? target;
element.visitAncestorElements((parent) {
if (parent.widget is T) {
target = parent;
return false;
}
return true;
});
return target;
}