禁用向下拖动以关闭showModalBottomSheet [英] Disable drag down to close showModalBottomSheet

查看:458
本文介绍了禁用向下拖动以关闭showModalBottomSheet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何禁用/逃脱底部模态中的向下拖动手势,以便用户可以在模态中进行交互而不会意外关闭模态?

How do I disable / escape drag down gesture within the Bottom Sheet Modal so the user can interact within the modal without accidentally closing the modal?

下面以实际的模态底部工作表进行了更新.

Updated below with the actual modal bottom sheet.

return showModalBottomSheet(
    context: context,
    builder: (BuildContext context) {
        ...
    }
}

推荐答案

您可以尝试使用带有onVerticalDragStart =(_){}

you can try to wrap builder's result with GestureDetector with onVerticalDragStart = (_) {}

showModalBottomSheet(
  context: context,
  builder: (context) => GestureDetector(
    child: **any_widget_here**,
    onVerticalDragStart: (_) {},
  ),
  isDismissible: false,
  isScrollControlled: true,
);

这篇关于禁用向下拖动以关闭showModalBottomSheet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆