selections property Null safety

List<TextSelection> selections
visibleForTesting">@visibleForTesting

The ongoing selections in this paragraph.

The selection does not include selections in PlaceholderSpan if there are any.

Implementation

@visibleForTesting
List<TextSelection> get selections {
  if (_lastSelectableFragments == null) {
    return const <TextSelection>[];
  }
  final List<TextSelection> results = <TextSelection>[];
  for (final _SelectableFragment fragment in _lastSelectableFragments!) {
    if (fragment._textSelectionStart != null &&
        fragment._textSelectionEnd != null &&
        fragment._textSelectionStart!.offset != fragment._textSelectionEnd!.offset) {
      results.add(
        TextSelection(
          baseOffset: fragment._textSelectionStart!.offset,
          extentOffset: fragment._textSelectionEnd!.offset
        )
      );
    }
  }
  return results;
}