美文网首页
flutter-输入框空白长按不弹出选项

flutter-输入框空白长按不弹出选项

作者: ChaosHeart | 来源:发表于2021-01-04 10:13 被阅读0次

问题:

有复制时
flutter-输入框空白长按不弹出选项

解决:

截屏2020-12-29 15.00.16.png

参考:


截屏2022-03-09 10.14.20.png
void _handleSelectionChange(
    TextSelection nextSelection,
    SelectionChangedCause cause,
  ) {
    // Changes made by the keyboard can sometimes be "out of band" for listening
    // components, so always send those events, even if we didn't think it
    // changed. Also, focusing an empty field is sent as a selection change even
    // if the selection offset didn't change.
    final bool focusingEmpty = nextSelection.baseOffset == 0 && nextSelection.extentOffset == 0 && !hasFocus;
    //原生代码
    // if (nextSelection == selection && cause != SelectionChangedCause.keyboard && !focusingEmpty) {
    //   return;
    // }
    //修改后代码
    if (nextSelection == selection && nextSelection.end - nextSelection.start > 0) {
      return;
    }
    if (onSelectionChanged != null) {
      onSelectionChanged!(nextSelection, this, cause);
    }
  }

相关文章

网友评论

      本文标题:flutter-输入框空白长按不弹出选项

      本文链接:https://www.haomeiwen.com/subject/xvihoktx.html