wip
parent
79c5b8fa4b
commit
f0e2ce16f2
|
@ -32,7 +32,12 @@ class SliderState extends State<MySlider> {
|
|||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Slider(
|
||||
SliderTheme(
|
||||
data: SliderThemeData(
|
||||
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 8.0),
|
||||
trackHeight: 2.0,
|
||||
),
|
||||
child: Slider(
|
||||
value: _currentSliderValue,
|
||||
min: 1,
|
||||
max: 100,
|
||||
|
@ -41,15 +46,16 @@ class SliderState extends State<MySlider> {
|
|||
onChanged: (double value) {
|
||||
setState(() {
|
||||
_currentSliderValue = value;
|
||||
_textFieldController.text = _currentSliderValue.toString();
|
||||
_textFieldController.text =
|
||||
_currentSliderValue.toString();
|
||||
_errorText = null;
|
||||
});
|
||||
}),
|
||||
Text(_currentSliderValue.round().toString())
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
TextFormField(
|
||||
SizedBox(width: 16.0),
|
||||
SizedBox(
|
||||
width: 50,
|
||||
child: TextFormField(
|
||||
controller: _textFieldController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
|
@ -68,7 +74,8 @@ class SliderState extends State<MySlider> {
|
|||
if (value == null || value < 1 || value > 100) {
|
||||
setState(() {
|
||||
_textFieldController.clear();
|
||||
_errorText = 'Please enter a value between 1 and 100.';
|
||||
_errorText =
|
||||
'Please enter a value between 1 and 100.';
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -78,6 +85,9 @@ class SliderState extends State<MySlider> {
|
|||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue