美文网首页
flutter滑动选择器slider

flutter滑动选择器slider

作者: wrootlflvl | 来源:发表于2019-06-26 10:31 被阅读0次
    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('Slider'), 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: Colors.blue, // 进度条高亮颜色
                      inactiveColor: Colors.blue.withOpacity(0.3), // 进度条背景色
                      min: 0.0, // 设置最小值
                      max: 10.0, // 设置最大值
                      divisions: 10, // 设置分成几等份
                      label: '${_sliderItemA.toInt()}', // 进度条上面的标签
                    )
                  ],
                ),
                SizedBox(height: 16.0,),
                Text('SliderValue: ${_sliderItemA.toInt()}'),
              ],
            ),
          ),
        );
      }
    }
    

    相关文章

      网友评论

          本文标题:flutter滑动选择器slider

          本文链接:https://www.haomeiwen.com/subject/jzmqcctx.html