flutter - 颤振滑块小部件没有动画
问题描述
我编写了滑块小部件的代码,您可以在其中通过滑动获取高度。但问题是,当您在控制台中打印高度时,它是正确的。但是滑块既不移动,运行时高度值也没有变化。我什至构建了一个 APK,但问题仍然存在于物理设备中。
SliderTheme(
data: SliderTheme.of(context).copyWith(
inactiveTrackColor: Color(0xFF8D8E98),
activeTrackColor: Colors.white,
thumbColor: Color(0xFFEB1555),
overlayColor: Color(0x29EB1555),
thumbShape:
RoundSliderThumbShape(enabledThumbRadius: 15.0),
overlayShape:
RoundSliderOverlayShape(overlayRadius: 30.0),
),
child: Slider(
value: height.toDouble(),
min: 120.0,
max: 220.0,
onChanged: (double newValue) {
setState(() {
height = newValue.round();
});
},
),
),
甚至使用了 setState 方法。int height 已经声明。
解决方案
我发现了我在
@override Widget build(BuildContext context)
方法中初始化高度值的问题。相反,高度值应该在
_InputPageState(stateful widget class)
方法之外的
@override Widget build(BuildContext context)
方法中初始化
推荐阅读
- vba - MS Visio 中的 VBA - 突出显示选定形状的连接器
- java - 为什么插入符号“^”不适用于 Java+Selenium+Eclipse?
- firebase - Firebase OnAuthStateChanged for Phone Auth 即使在 iOS 上也会触发
- node.js - firebase deploy --only hosting 给出错误:HTTP 错误:410,未知错误
- c - C 中的函数指针是如何工作的?- 具体例子
- python - Selenium (Python):getAttribute('value') 无法从文本输入中获取文本
- react-google-maps - react-google-maps:如何在父组件中使用 fitBounds API
- r - 为什么我的 R 箱线图中的变量不能反映我的实际数据?
- javascript - Chrome 中的 ES6 模块
- c++ - 在测试中使用部分初始化的对象