Slider(每日Flutter 小部件)


滑動條

const Slider({
  Key key,
  @required this.value,   //當前值
  @required this.onChanged,  //改變回調
  this.onChangeStart,
  this.onChangeEnd,
  this.min = 0.0,
  this.max = 1.0,
  this.divisions, //多少個刻度
  this.label,  //滑塊上顯示的文案
  this.activeColor,  //活動區域顏色
  this.inactiveColor, //非活動區域顏色
  this.semanticFormatterCallback, // 用於根據滑塊值創建語義值的回調。例:semanticFormatterCallback: (double newValue) {return '${newValue.round()} dollars}';},

  

 

class SliderWidget extends StatefulWidget {
  SliderWidget({Key key}) : super(key: key);

  _SliderWidgetState createState() => _SliderWidgetState();
}

class _SliderWidgetState extends State<SliderWidget> {
  double _sliderValue = 0;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Slider(
          value: _sliderValue,
          onChanged: (double value) {
            setState(() {
              this._sliderValue = value;
            });
          },
          min: 0,
          max: 100,
          divisions: 100,
          label: '進度:$_sliderValue',
          activeColor: Colors.red,
          inactiveColor: Colors.purple,
          semanticFormatterCallback: (double value) {
            return '進度:$_sliderValue';
          }),
    );
  }
}

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM