1, Flutter :Slider,CupertinoSlider
- Slider
- CupertinoSlider
What is failure? Nothing, just a step closer to success; What is success? Is through all the way to failure, only one way, that is the way to success.
Slider
Common style progress bar
Bold is a mandatory parameter
Slider Progress bar parameter | type | instructions |
---|---|---|
label | String | For use by Divisions |
divisions | int | To divide the video into five segments, you can only slide to a certain point on the five segments |
activeColor | Color | The color has been slid |
inactiveColor | Color | Unslided color |
min | double | The default is 0.0. Must be less than or equal to [maximum] If [Max] is equal to [min], the slider is disabled. |
max | double | The default is 1.0. The value must be greater than or equal to [min]. If [Max] is equal to [min], the slider is disabled. |
value | double | Current progress value (0-1) |
onChanged | ValueChanged | Progress bar Progress return value is (0-1) |
onChangeStart | ValueChanged | Slide to start the callback |
onChangeEnd | ValueChanged | Slide to end the callback |
// The current video progress bar is displayed
double _slidervalue = 0.0;
// Slide the progress bar
Widget buildSilder(a) {
return Row(
children: [
// Start text
Text(
"0.0",
style: TextStyle(fontSize: 14, color: Colors.white),
),
Expanded(
child: Slider(
// Divisions are available for use
label: "$_slidervalue _slidervalue"./// To divide the video into 5 segments, you can only slide to a certain position on the 5 segments
divisions: 5./// the color has been slid
activeColor: Colors.red,
/// Unslided colors
inactiveColor: Colors.cyan,
/// Default is 0.0. Must be less than or equal to [maximum]
/// If [Max] equals [min], the slider is disabled.
min: 0./// The default is 1.0. The value must be greater than or equal to [min].
/// If [Max] equals [min], the slider is disabled.
max: 1./// Current progress value (0-1)
value: _slidervalue,
// Progress bar progress returns (0-1)
onChanged: (double value) {
setState(() {
_slidervalue = value;
});
},
// Slide to start the callback
onChangeStart: (double value){
Toast.toast(context,msg: "Slide start $value");
},
// Slide to end the callback
onChangeEnd: (double value){
Toast.toast(context,msg: "Slide end $value"); },),),// End the text
Text(
"0.0",
style: TextStyle(fontSize: 14, color: Colors.white),
),
],
);
}
Copy the code
Rendering (1.1)
CupertinoSlider
Apple style slider
Bold is a mandatory parameter
CupertinoSlider progress bar parameters | type | instructions |
---|---|---|
divisions | int | To divide the video into five segments, you can only slide to a certain point on the five segments |
activeColor | Color | Progress bar color |
thumbColor | Color | Slide button color |
min | double | The default is 0.0. Must be less than or equal to [maximum] If [Max] is equal to [min], the slider is disabled. |
max | double | The default is 1.0. The value must be greater than or equal to [min]. If [Max] is equal to [min], the slider is disabled. |
value | double | Current progress value (0-1) |
onChanged | ValueChanged | Progress bar Progress return value is (0-1) |
onChangeStart | ValueChanged | Slide to start the callback |
onChangeEnd | ValueChanged | Slide to end the callback |
/// Apple style slider
Widget initCupertinoSlider(a) {
return CupertinoSlider(
// /// divides the video into 5 segments and can only slide to a certain location on the 5 segments
divisions: 5./// the color has been slid
activeColor: Colors.red,
/// Unslided colors
thumbColor: Colors.cyan,
/// Default is 0.0. Must be less than or equal to [maximum]
/// If [Max] equals [min], the slider is disabled.
min: 0./// The default is 1.0. The value must be greater than or equal to [min].
/// If [Max] equals [min], the slider is disabled.
max: 1./// Current progress value (0-1)
value: _slidervalue,
// Progress bar progress returns (0-1)
onChanged: (double value) {
setState(() {
_slidervalue = value;
// Drag the progress bar to change the video length
});
},
// Slide to start the callback
onChangeStart: (double value) {
Toast.toast(context, msg: "Slide start $value");
},
// Slide to end the callback
onChangeEnd: (double value) {
Toast.toast(context, msg: "Slide end $value"); }); }Copy the code
Rendering (1.2) :
Use the Demo:
ListView plays video lists on Flutter
What do you like?
The Flutter Slider,CupertinoSlider Slider
Flutter Sliver family CustomScrollView and SliverAppBar components
The SliverList(),SliverFixedExtentList(),SliverGrid() components of Flutter
SliverPersistentHeader() and SliverToBoxAdapter() components of the Flutter family
Original is not easy, your thumbs up is my biggest support, leave your thumbs up ~