findAncestorWidgetOfExactType<T extends Widget> method
T?
findAncestorWidgetOfExactType<T extends Widget>()
Returns the nearest ancestor widget of the given type T.
Implementation
T? findAncestorWidgetOfExactType<T extends Widget>() {
Element? current = _parent;
while (current != null) {
if (current.widget.runtimeType == T) {
return current.widget as T;
}
current = current._parent;
}
return null;
}