不点击菜单项即可取消SelectableText的上下文菜单。
创始人
2024-12-23 13:03:14
0

要取消SelectableText的上下文菜单而不点击菜单项,可以使用LongPressGestureRecognizer来检测长按手势,并在手势识别器回调中禁用默认的上下文菜单。

下面是一个示例代码:

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Disable SelectableText Context Menu'),
        ),
        body: Center(
          child: GestureDetector(
            onLongPress: () {}, // 空回调函数,什么也不做
            child: SelectableText(
              'Long press here to disable context menu',
              enableInteractiveSelection: true,
              // 设置为true以启用可选文本
              showCursor: true,
              // 显示光标
              cursorWidth: 2.0,
              // 光标宽度
              cursorRadius: Radius.circular(5),
              // 光标半径
              style: TextStyle(fontSize: 20),
            ),
          ),
        ),
      ),
    );
  }
}

在这个示例中,我们使用了一个空的onLongPress回调函数来禁用默认的上下文菜单。当用户长按SelectableText时,不会显示任何菜单项。

相关内容

热门资讯

透视最新!aapoker发牌逻... 透视最新!aapoker发牌逻辑(透视)ai插件(都是是真的有挂);所有人都在同一条线上,像星星一样...
透视科技!aapoker透视脚... 透视科技!aapoker透视脚本入口(透视)透视方法(竟然真的是有挂)1、首先打开aapoker透视...
透视数据!aapoker插件下... 透视数据!aapoker插件下载(透视)透视脚本下载(竟然是有挂)1、首先打开aapoker插件下载...
透视透视!aapoker破解侠... 透视透视!aapoker破解侠是真的吗(透视)发牌逻辑(竟然是真的有挂);aapoker破解侠是真的...
辅助透视!aapoker辅助怎... 辅助透视!aapoker辅助怎么用(透视)透视脚本(一贯真的是有挂)进入游戏-大厅左侧-新手福利-激...
透视安装!aapoker辅助器... 透视安装!aapoker辅助器怎么用(透视)透视脚本入口(原来有挂)1、aapoker辅助器怎么用a...
透视辅助!aapoker透视方... 透视辅助!aapoker透视方法(透视)插件下载(一贯是真的有挂)透视辅助!aapoker透视方法(...
透视攻略!aapoker能控制... 透视攻略!aapoker能控制牌吗(透视)辅助插件工具(原来是真的有挂);小薇(透视辅助)致您一封信...
透视脚本!aa poker透视... 透视脚本!aa poker透视软件(透视)辅助(好像有挂)1、aa poker透视软件透视辅助简单,...
透视软件!aapoker能控制... 透视软件!aapoker能控制牌吗(透视)辅助插件工具(切实真的是有挂)1、全新机制【aapoker...