findWidgetForComponent<WidgetType> static method
Finds and returns the Widget that configures the DocumentComponent with the
given nodeId.
The given nodeId must exist in the SuperEditor's document. The Widget that
configures the give node must be of type WidgetType.
By default, this method expects a single SuperEditor in the widget tree and
finds it byType. To specify one SuperEditor among many, pass a superEditorFinder.
Implementation
static WidgetType findWidgetForComponent<WidgetType>(String nodeId, [Finder? superEditorFinder]) {
final documentLayout = _findDocumentLayout(superEditorFinder);
final widget = (documentLayout.getComponentByNodeId(nodeId) as State).widget;
if (widget is! WidgetType) {
throw Exception("Looking for a component's widget. Expected type $WidgetType, but found ${widget.runtimeType}");
}
return widget as WidgetType;
}