findAncestorWidgetOfExactType<T extends Widget> method
Returns the nearest ancestor widget of the given type T
, which must be
the type of a concrete Widget subclass.
Implementation
@override
T? findAncestorWidgetOfExactType<T extends Widget>() {
RenderElement? ancestor = _parent;
var matchType = '$T';
while (null != ancestor && ancestor.widgetRuntimeType != matchType) {
ancestor = ancestor._parent;
}
return ancestor?.widget as T?;
}