flutter - 如何使自定义滑块覆盖颜色与颤动中的拇指颜色不同?
问题描述
我试图在颤振中实现一个自定义滑块 SliderTheme.of(context).copywith()
,但是当为拇指及其叠加层分配颜色时,它们都变得相同thumbColor
。
这是我的结果
我的代码是:
SliderTheme(
data: SliderTheme.of(context).copyWith(
activeTrackColor: Colors.white,
thumbColor: Color(0xffeb1555),
overlayColor: Color(0x29eb1555),
thumbShape:
RoundSliderThumbShape(enabledThumbRadius: 10.0),
overlayShape:
RoundSliderThumbShape(enabledThumbRadius: 20.0),
),
child: Slider(
value: height.toDouble(),
min: 100.0,
max: 220.0,
divisions: 120,
onChanged: (double newVal) {
setState(() {
height = newVal.toInt();
});
},
),
),
欢迎任何帮助。谢谢
解决方案
你需要改变
overlayShape: RoundSliderThumbShape(enabledThumbRadius: 20.0),
至
overlayShape: RoundSliderOverlayShape(overlayRadius: 20.0),
注意 - 它必须是 OVERLAY 形状
推荐阅读
- r - Tidymodels Logistic Regression 获取系数和标准误差
- flutter - 如何在颤动中条件性地渲染堆栈内的子小部件?
- unity3d - 将动画师与另一个动画师混合的任何解决方案?
- ios - SceneKit,动态加载和替换纹理的最有效方法是什么?UIImage,MTLTexture,MDLTexture,URL?
- reactjs - typescript 不会在 reac-router-dom 上呈现动态 url
- javascript - HTML、JS、video.js 中的视频自动播放
- ruby-on-rails - Rails Lockbox - Lockbox Gem - 未定义方法:解密
- jquery - jquery - 当为 animate() 传递多个元素时,自定义函数提前返回的承诺/延迟
- sql - 如果 SQL IN 运算符中的字符串为空,则选择所有数据
- ios - Swift 如何使用表格视图单元格中的按钮更新子视图的标签和图像视图