android - 如何在 Flutter 中删除动画?
问题描述
我想删除动画并打印,result
但我不知道如何从中删除动画result
这里result
是:
onPressed: () => Navigator.of(context).push(MaterialPageRoute(
builder: (context) => NextPage(
result: (something + other_thing)
这就是我打印它的方式:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ValueListenableBuilder<String>(
valueListenable: _animation,
builder: (context, value, child) {
return Text(
'The result is $value', //It has to print the result here, but without any animations
style: Theme.of(context).textTheme.headline5,
textAlign: TextAlign.center,
);
},
),
],
),
),
);
}
}
我想知道是否需要删除此 ValueListenableBuilder,但我不知道如何result
从上面的代码中访问。
解决方案
除非您需要使用 ValueListenableBuilder,否则您可以使用它Navigator.push
来帮助您在不同屏幕之间移动数据而无需动画。如果您不知道 Navigator 的工作原理,这里有一个简单的视频来解释它的工作原理。https://www.youtube.com/watch?v=NT3XakU4Dcw
推荐阅读
- flutter - Scaffold.of() 在显示小吃店颤动时使用不包含 Scaffold 错误的上下文调用
- excel - Excel VBA If语句多条件运行时报错13
- jquery - jQuery submit 方法适用于 Android 但不适用于 iOS
- ios - 如何在 Swift 中正确存储用户设置?
- java - 如何在 Android 中创建侧边导航栏
- python - 如何修复基于文本的冒险游戏中的缩进错误
- mapbox - Qt 5.12 上缺少图标
- c# - Do/While 循环递增,生成星号,每行递增一颗星
- arrays - 解析 VBA 字典中的数组项时下标超出范围 - 不能使用索引 0
- java - 将 XML 字符串附加到 Java 中的元素