flutter - 向下滚动内部可滚动时关闭底部工作表
问题描述
我有 Flutter 的全屏模态底页,SingleChildScrollView
里面有它。
正常结果是,无论我向上还是向下滚动,它都会滚动内部可滚动。我可以通过向下拖动可滚动之外的任何内容来关闭模态底部工作表(对我来说,这是一个带有拖动手柄的小容器)。
问题是如果我拉下内部可滚动,我想拉下底页。在做了一些研究之后,我发现我应该使用AlwaysScrollableScrollPhysics
,NeverScrollableScrollPhysics
但我真的找不到最好的解决方案。
我的想法是允许内部可滚动滚动,直到它的滚动偏移为负。那是行不通的,因为当我停止滚动而不关闭底部工作表时,我需要某种方法使其可滚动。
我可以将内部可滚动包装到GestureDetector
并检查滚动增量,但还没有成功。
也许有人遇到过类似的问题并得到了一些例子或算法?
解决方案
添加modal_bottom_sheet并使用showMaterialModalBottomSheet
showMaterialModalBottomSheet(
context: context,
builder: (context) {
return SingleChildScrollView(
child: Column(
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.8,
color: Colors.green,
),
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.8,
color: Colors.red,
),
],
),
);
});
推荐阅读
- javascript - 我无法用cropperjs 裁剪图像
- r - as.Date.numeric() 中的错误:必须提供“原点”
- java - 如何在 Java 中将 HexString 编码为 Base64 RFC 1421
- javascript - 在使用 reactjs 在 Firestore 中获取具有参考 ID 的文档时需要帮助
- android-layout - 如何在列表中显示不同的小部件:Flutter
- sql - SQL 查询 - 从另一个表添加列数据并添加空值
- sql - 如何在 SQL 中根据文本数据生成计数
- haskell - haskell 导入 Data.List 模块失败
- ionic-framework - 如何在 Ionic 4/5 中拖动元素
- embedded - 使用示波器测量 USB 电缆的功率