forked from md-siam/widget_of_the_day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslider.dart
53 lines (49 loc) · 1.32 KB
/
slider.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import 'package:flutter/material.dart';
class MySlider extends StatefulWidget {
const MySlider({Key? key}) : super(key: key);
@override
_MySliderState createState() => _MySliderState();
}
class _MySliderState extends State<MySlider> {
// create variable
double _currentValue = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.deepPurple[200],
appBar: AppBar(
title: const Text('S L I D E R'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
_currentValue.toString(),
style: const TextStyle(
fontSize: 50,
fontWeight: FontWeight.bold,
color: Colors.yellow,
),
),
Slider(
value: _currentValue,
min: 0,
max: 10,
divisions: 4,
label: _currentValue.toString(),
activeColor: Colors.yellow,
inactiveColor: Colors.red,
thumbColor: Colors.green,
onChanged: (value) {
setState(() {
_currentValue = value;
});
},
),
],
),
),
);
}
}