![](/img/trans.png)
[英]How to make dot indicator carousel slider in flutter using asset/images?
[英]How to change font size on flutter using a slider indicator?
下面的代码只更改了 1-10 的滑块,如何在 Flutter 中更改滑块的同时更改文本?
文本是从 API 中获取的。
double _value = 0.0;
[enter image description here][1] bool _slider = false;
child: _slider == true
? new Container(
margin: EdgeInsets.only(right: 10),
decoration: new BoxDecoration(
color: NNDColors.main,
borderRadius: new BorderRadius.all(
new Radius.circular(5.0)),
boxShadow: [
new BoxShadow(
color: Colors.black38,
offset: new Offset(0.0, 2.0),
blurRadius: 10)
]),
child: new Slider(
value: _value,
activeColor: Colors.white,
inactiveColor: Colors.white,
onChanged: (double s) => _changed(s),
divisions: 10,
min: 0.0,
max: 10.0,
),
void _changed(s) {
setState((){
_value = s;
});
}
输出:
这是您如何做到的。
double _value = 5;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Testing")),
body: Center(
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.only(right: 10),
decoration: new BoxDecoration(
color: Colors.blue,
borderRadius: new BorderRadius.all(new Radius.circular(5.0)),
boxShadow: [new BoxShadow(color: Colors.black38, offset: new Offset(0.0, 2.0), blurRadius: 10)]),
child: new Slider(
value: _value,
activeColor: Colors.white,
inactiveColor: Colors.white,
onChanged: (double s) {
setState(() {
_value = s;
});
},
divisions: 10,
min: 0.0,
max: 10.0,
),
),
Text("Hello World", style: TextStyle(fontSize: 10 * _value)),
],
),
),
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.