findTextInParagraph static method

AttributedText findTextInParagraph(
  1. String nodeId, [
  2. Finder? superDocumentFinder
])

Returns the AttributedText within the ParagraphNode associated with the given nodeId.

There must be a ParagraphNode with the given nodeId, displayed in a SuperReader.

By default, this method expects a single SuperReader in the widget tree and finds it byType. To specify one SuperReader among many, pass a superDocumentFinder.

Implementation

static AttributedText findTextInParagraph(String nodeId, [Finder? superDocumentFinder]) {
  final documentLayout = _findDocumentLayout(superDocumentFinder);
  final component = documentLayout.getComponentByNodeId(nodeId);

  if (component is TextComponentState) {
    return component.widget.text;
  }

  if (component is ProxyDocumentComponent) {
    return (component.childDocumentComponentKey.currentState as TextComponentState).widget.text;
  }

  throw Exception('The component for node id $nodeId is not a TextComponent.');
}