blobNodeFor static method
Returns the BlobNode that most closely corresponds to a given BuildContext.
If the context
is not a remote widget and has no ancestor remote widget,
then this function returns null.
The BlobNode is typically either a WidgetDeclaration (whose WidgetDeclaration.root argument is a ConstructorCall or a Switch that resolves to a ConstructorCall), indicating the BuildContext maps to a remote widget, or a ConstructorCall directly, in the case where it maps to a local widget. Widgets that correspond to render objects (i.e. anything that might be found by hit testing on the screen) are always local widgets.
Implementation
static BlobNode? blobNodeFor(BuildContext context) {
if (context.widget is! _Widget) {
context.visitAncestorElements((Element element) {
if (element.widget is _Widget) {
context = element;
return false;
}
return true;
});
}
if (context.widget is! _Widget) {
return null;
}
return (context.widget as _Widget).curriedWidget;
}