cut method

  1. @override
TextEditingValue? cut(
  1. ZefyrController controller,
  2. String plainText
)
override

Implementation

@override
TextEditingValue? cut(ZefyrController controller, String plainText) {
  if (!controller.selection.isCollapsed) {
    final data = controller.selection.textInside(plainText);
    // ignore: unawaited_futures
    Clipboard.setData(ClipboardData(text: data));

    controller.replaceText(
      controller.selection.start,
      data.length,
      '',
      selection: TextSelection.collapsed(offset: controller.selection.start),
    );

    return TextEditingValue(
      text: controller.selection.textBefore(plainText) +
          controller.selection.textAfter(plainText),
      selection: TextSelection.collapsed(offset: controller.selection.start),
    );
  }
}