findParagraphStyle static method

TextStyle? findParagraphStyle(
  1. String nodeId, [
  2. Finder? superDocumentFinder
])

Finds and returns the TextStyle that's applied to the top-level of the TextSpan in the paragraph with the given nodeId.

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 TextStyle? findParagraphStyle(String nodeId, [Finder? superDocumentFinder]) {
  final documentLayout = _findDocumentLayout(superDocumentFinder);

  final textComponentState = documentLayout.getComponentByNodeId(nodeId) as TextComponentState;
  final superTextWithSelection = find
      .descendant(of: find.byWidget(textComponentState.widget), matching: find.byType(SuperTextWithSelection))
      .evaluate()
      .single
      .widget as SuperTextWithSelection;
  return superTextWithSelection.richText.style;
}