From f0e2ce16f2452cb3722887f00601978b451fb66f Mon Sep 17 00:00:00 2001 From: Parricc35 <63447810+Parricc35@users.noreply.github.com> Date: Tue, 21 Feb 2023 00:20:43 +0100 Subject: [PATCH] wip --- lib/widgets/slider.dart | 90 +++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/lib/widgets/slider.dart b/lib/widgets/slider.dart index 4c6b28b..928c3ba 100644 --- a/lib/widgets/slider.dart +++ b/lib/widgets/slider.dart @@ -32,52 +32,62 @@ class SliderState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Slider( - value: _currentSliderValue, - min: 1, - max: 100, - divisions: 99, - label: _currentSliderValue.round().toString(), - onChanged: (double value) { + SliderTheme( + data: SliderThemeData( + thumbShape: RoundSliderThumbShape(enabledThumbRadius: 8.0), + trackHeight: 2.0, + ), + child: Slider( + value: _currentSliderValue, + min: 1, + max: 100, + divisions: 99, + label: _currentSliderValue.round().toString(), + onChanged: (double value) { + setState(() { + _currentSliderValue = value; + _textFieldController.text = + _currentSliderValue.toString(); + _errorText = null; + }); + }), + ), + SizedBox(width: 16.0), + SizedBox( + width: 50, + child: TextFormField( + controller: _textFieldController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: 'Enter value', + errorText: _errorText, + ), + onChanged: (text) { + if (text.isEmpty) { + _currentSliderValue = 0; + setState(() { + _errorText = null; + }); + return; + } + final value = double.tryParse(text); + if (value == null || value < 1 || value > 100) { + setState(() { + _textFieldController.clear(); + _errorText = + 'Please enter a value between 1 and 100.'; + }); + return; + } setState(() { _currentSliderValue = value; - _textFieldController.text = _currentSliderValue.toString(); _errorText = null; }); - }), - Text(_currentSliderValue.round().toString()) + }, + ), + ), ], ), - SizedBox(height: 16), - TextFormField( - controller: _textFieldController, - keyboardType: TextInputType.number, - decoration: InputDecoration( - labelText: 'Enter value', - errorText: _errorText, - ), - onChanged: (text) { - if (text.isEmpty) { - _currentSliderValue = 0; - setState(() { - _errorText = null; - }); - return; - } - final value = double.tryParse(text); - if (value == null || value < 1 || value > 100) { - setState(() { - _textFieldController.clear(); - _errorText = 'Please enter a value between 1 and 100.'; - }); - return; - } - setState(() { - _currentSliderValue = value; - _errorText = null; - }); - }, - ), ], ); }