小编Pra*_*nav的帖子

如何增加onLongPress的时间限制?

我对扑动相当陌生。我知道当用户触摸屏幕超过 500 毫秒时会触发长按。有没有办法将其更改为大约 2 秒?

在我的代码中,我使用 inkresponse 从 fab 获取两个不同的函数。点击时会转到第一页,长按时会转到第二页。我希望长按时间更长,并且可能添加动画来指示按钮被按下。

这是我写的代码-

floatingActionButtonLocation: 
  FloatingActionButtonLocation.endFloat,
      floatingActionButton: InkResponse(
        splashColor: Colors.tealAccent,
             onLongPress: () {
          Navigator.of(context).push(new MaterialPageRoute(
          builder: (BuildContext context) => new firstPage(),));
          },
        child: new Container(
          width: 57.0,
          height: 57.0,

          child: Align(
          alignment: Alignment(1, 1.05),
           child: FloatingActionButton(
            onPressed: () {
                Navigator.of(context).push(new MaterialPageRoute(
                builder: (BuildContext context) => new secondpage(),
              ));},
        ),),
      ),),
Run Code Online (Sandbox Code Playgroud)

flutter

6
推荐指数
1
解决办法
2014
查看次数

标签 统计

flutter ×1