Flutter series overall directory
Attributes | Explanation |
---|---|
value | Position control |
onChanged | Callback change |
onChangeStart | Once when the slide began to call back |
onChangeEnd | Callback once the end of the slide |
me | Minimum |
max | Maximum |
divisions | Divided into pieces, such as setting 5, Slider slides only 5 positions |
label | divisions disposed on the node label displayed |
activeColor | Color slides over a region |
inactiveColor | Color is not slid over the region |
example:
import 'package:flutter/material.dart';
class SliderDemo extends StatefulWidget {
@override
State<StatefulWidget> createState() => _SliderDemo();
}
class _SliderDemo extends State<SliderDemo> {
double _value = 0;
int _dollars = 20;
@override
Widget build(BuildContext context) {
// TODO: implement build
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Slider(
value: _value,
onChanged: (newValue) {
print('onChanged:$newValue');
setState(() {
_value = newValue;
});
},
onChangeStart: (startValue) {
print('onChangeStart:$startValue');
},
onChangeEnd: (endValue) {
print('onChangeEnd:$endValue');
},
label: '$_value dollars',
divisions: 5,
semanticFormatterCallback: (newValue) {
return '${newValue.round()} dollars';
},
),
Slider(
value: _dollars.toDouble(),
min: 20.0,
max: 330.0,
label: '$_dollars dollars',
onChanged: (double newValue) {
setState(() {
_dollars = newValue.round();
});
},
semanticFormatterCallback: (double newValue) {
return '${newValue.round()} dollars';
}),
],
);
}
}