initialText method

String initialText()

Returns the first non-empty text in the span, or the empty string if none.

Note, a WidgetSpan is represented as '\uFFFC', the standard object replacement character.

Implementation

String initialText() {
  return valueOfFirstDescendantOf(
        this,
        where: (s) =>
            s is WidgetSpan ||
            (s is TextSpan && (s.text?.isNotEmpty ?? false)),
        defaultValue: '',
        getValue: (s) => s is WidgetSpan
            ? '\uFFFC'
            : s is TextSpan && (s.text?.isNotEmpty ?? false)
                ? s.text
                : '',
        childrenOf: (s) => s is TextSpan ? s.children : null,
        isValueInherited: false,
      ) ??
      '';
}