flutter Slider滑块组件
滑块,允许用户通过滑动滑块来从一系列值中选择。
import 'package:flutter/material.dart'; class SliderDemo extends StatefulWidget { @override _SliderDemoState createState() => _SliderDemoState(); } class _SliderDemoState extends State<SliderDemo> { double _sliderItemA = 0.0; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('SliderDemo'), elevation: 0.0, ), body: Container( padding: EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Slider( value: _sliderItemA, onChanged: (value) { setState(() { _sliderItemA = value; }); }, activeColor: Theme.of(context).accentColor, inactiveColor: Theme.of(context).accentColor.withOpacity(0.3), min: 0.0, max: 10.0, divisions: 10, label: '${_sliderItemA.toInt()}', ), ], ), SizedBox(height: 16.0,), Text('SliderValue: $_sliderItemA'), ], ), ) ); } }
效果:
最后,关注【码上加油站】微信公众号后,有疑惑有问题想加油的小伙伴可以码上加入社群,让我们一起码上加油吧!!!
posted on 2019-08-12 21:20 LoaderMan 阅读(1744) 评论(0) 编辑 收藏 举报