findParagraphStyle static method

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

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 SuperEditor in the widget tree and finds it byType. To specify one SuperEditor among many, pass a superEditorFinder.

Implementation

static TextStyle? findParagraphStyle(String nodeId, [Finder? superEditorFinder]) {
  final documentLayout = _findDocumentLayout(superEditorFinder);

  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;
}