android - 禁用在底部工作表模式上的拖动
问题描述
我想使用一个模态的 bottomSheetModal,我想在其中显示一个带有一些元素的 gridView。我使用showModalBottomSheet
方法将模态带入视图。
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 2,
color: Colors.grey[300],
child: CategoryModal(),
);
},
);
在 CategoryModal 我有一个从数据库中获取一些数据的未来:
CategoryModal extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
...
Expanded(
child: FutureBuilder<List<Category>>(
future: CategoryRepository.getAll(),
builder: (BuildContext context, AsyncSnapshot<List<Category>> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return Text(
snapshot.error.toString(),
);
}
return getCategoriesGrid(snapshot.data);
}
return Text("Loading");
}),
),
],
),
);
}
}
我遇到的问题是,modal有可拖动的选项来关闭,如果我慢慢往下拉,每次都会刷新数据。我发现 BottomSheet 类有一个参数,enableDrag
它禁用拖动,但不适用于该showModalBottomSheet
方法。
有没有办法停止刷新数据或禁用模式的拖动选项?
解决方案
这是您的问题的解决方案,
showModalBottomSheet(
context: context,
enableDrag: false,
isScrollControlled: true,
推荐阅读
- installation - 无法安装 laravel 黄昏仪表板
- node.js - 从 Axios 获取图像并作为表单数据发送到云函数中的 Wordpress API
- flutter - 计算两组日期之间的差异并在 Flutter 中划分结果
- laravel - Laravel 添加到 config/app 程序中的 poviders 数组
- php - Laravel 自定义计划日志
- python-3.x - 如何使用 Poetry 在 python 轮中包含符号链接和链接文件?
- sql - 如何检查表中是否存在值 - postgres PLPGSQL
- authentication - JHipster:如何限制用户使用 REST 访问自己的数据
- php - 不正确的 player_id 格式(不是有效的 UUID)
- javascript - Javascript:从 .cvs 文件中的两列创建数组