flutter - 如何在内容维度发生变化时停止滚动视图的滚动模拟?
问题描述
我准备了一个带有水平滚动容器的简单应用程序。当我在滚动位置到达该maxScrollExtend
位置后更改可滚动容器的内容尺寸时应用滚动模拟。
我向 Flutter 社区询问了这个问题。他们告诉这是滚动的预期行为。但是,我需要限制滚动模拟。
请任何人告诉我如何限制滚动模拟或如何在没有模拟行为的情况下自定义滚动的解决方法。
复制过程:
- 运行以下简单示例。
- 在水平方向完全滚动并到达终点。
- 点击浮动按钮可在运行时更改大小。
代码片段:
class ScrollingSimulationDemo extends StatefulWidget {
NestedDemo({Key? key}) : super(key: key);
@override
_ScrollingSimulationDemoState createState() => _ScrollingSimulationDemoState();
}
class _ScrollingSimulationDemoState extends State<ScrollingSimulationDemo> {
double width = 500;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
color: Colors.lightBlue[100],
height: 350,
width: width,
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
width = 250.0;
setState(() {});
},
),
);
}
}
要检查此行为的 GitHub 问题,请参阅以下链接, https://github.com/flutter/flutter/issues/86711
解决方案
推荐阅读
- python - Pytest 对象未在更新视图中更新
- excel - 从 Excel 创建 Outlook 约会(Office 2013 和 Office 2016)
- java - 如何从 Android 依赖项中排除 jar 文件?
- php - 在 woocommerce 变化的下拉菜单中显示价格
- jquery - 如何使用数据表插件按日期(从最旧到最新)排序列
- php - 使用另一个数组创建新的唯一数组
- ionic-framework - 离子存储:奇怪的行为?
- ruby-on-rails - Rails 应用模型中的 ModelName.real
- visual-studio-2015 - 在您的 SSDT 数据库项目中混合服务器数据库和本地数据库
- excel - 添加工作表后,VBA Excel 代码停止执行