Flutter开发 Slider组件(如音量控制)
用于进度展示、音量控制。
属性 | 说明 |
---|---|
value | 当前值 |
max | 最大值 |
min | 最小值 |
divisions | 分成n份 |
activeColor | 滑块已划过的颜色 |
inactiveColor | 滑块未划过的颜色 |
label | 气泡,必须与divisions同时使用 |
void main() {runApp(MyPage());
}class MyPage extends StatelessWidget {const MyPage({super.key}); Widget build(BuildContext context) {return MaterialApp(theme: ThemeData(), home: RadioFul());}
}class MyState extends State {double cur = 0; Widget build(BuildContext context) {Slider slider = Slider(value: cur,max: 100,divisions: 10,activeColor: Colors.blue,inactiveColor: Colors.grey,onChanged: (value) {setState(() {cur = value;});},);return Scaffold(appBar: AppBar(title: Text("圆形图片"), centerTitle: true),body: slider,);}
}class RadioFul extends StatefulWidget { State<StatefulWidget> createState() {return MyState();}
}
添加了lable的样子