getSelectedContent method

  1. @override
SelectedContent? getSelectedContent()
override

Copies the selected contents of all Selectables.

Implementation

@override
SelectedContent? getSelectedContent() {
  final List<SelectedContent> selections = <SelectedContent>[
    for (final Selectable selectable in selectables)
      if (selectable.getSelectedContent() case final SelectedContent data) data,
  ];
  if (selections.isEmpty) {
    return null;
  }
  final StringBuffer buffer = StringBuffer();
  for (final SelectedContent selection in selections) {
    buffer.write(selection.plainText);
  }
  return SelectedContent(
    plainText: buffer.toString(),
  );
}