diff --git a/lib/widgets/mood_form.dart b/lib/widgets/mood_form.dart index e7e425b..78c3e43 100644 --- a/lib/widgets/mood_form.dart +++ b/lib/widgets/mood_form.dart @@ -14,7 +14,7 @@ class MoodForm extends StatefulWidget { class _MoodFormState extends State { final GlobalKey _moodFormKey = GlobalKey(); - MySlider slider = const MySlider(); + MySlider slider = MySlider(); String _textInput = ""; void submitForm() { diff --git a/lib/widgets/popup_for_start_and_stop.dart b/lib/widgets/popup_for_start_and_stop.dart index 097e587..84f5383 100644 --- a/lib/widgets/popup_for_start_and_stop.dart +++ b/lib/widgets/popup_for_start_and_stop.dart @@ -13,7 +13,7 @@ class TimerStartStopPopup extends StatefulWidget { } class TimerStartStopPopupState extends State { - final MySlider slider = const MySlider(); + final MySlider slider = MySlider(); void submitForm(BuildContext context) { Navigator.of(context).pop(); @@ -29,8 +29,8 @@ class TimerStartStopPopupState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Padding( - padding: EdgeInsets.only(top: 8), + Padding( + padding: const EdgeInsets.only(top: 8), child: MySlider(labelText: 'Motivation'), ), const SizedBox(height: 16), diff --git a/lib/widgets/sleep_form.dart b/lib/widgets/sleep_form.dart index 32aab4d..5f8b9bd 100644 --- a/lib/widgets/sleep_form.dart +++ b/lib/widgets/sleep_form.dart @@ -14,7 +14,7 @@ class SleepForm extends StatefulWidget { class _SleepFormState extends State { final GlobalKey _sleepFormKey = GlobalKey(); - MySlider slider = const MySlider(); + MySlider slider = MySlider(); String _textInput = ""; TimePicker sleepTimePicker = TimePicker( const TimeOfDay(hour: 22, minute: 00), diff --git a/lib/widgets/slider.dart b/lib/widgets/slider.dart index 02f3fb8..0102014 100644 --- a/lib/widgets/slider.dart +++ b/lib/widgets/slider.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; -double _currentSliderValue = 50; - class MySlider extends StatefulWidget { + double _currentSliderValue = 50; final String _labelText; - const MySlider({Key? key, String labelText = 'Stimmung'}) + MySlider({Key? key, String labelText = 'Stimmung'}) : _labelText = labelText, super(key: key); @@ -23,7 +22,7 @@ class SliderState extends State { @override void initState() { super.initState(); - _textFieldController.text = _currentSliderValue.toStringAsFixed(0); + _textFieldController.text = widget._currentSliderValue.toStringAsFixed(0); } @override @@ -38,15 +37,16 @@ class SliderState extends State { children: [ Expanded( child: Slider( - value: _currentSliderValue, + value: widget._currentSliderValue, min: 1, max: 100, divisions: 99, - label: _currentSliderValue.round().toString(), + label: widget._currentSliderValue.round().toString(), onChanged: (double value) { setState(() { - _currentSliderValue = value; - _textFieldController.text = _currentSliderValue.toStringAsFixed(0); + widget._currentSliderValue = value; + _textFieldController.text = + widget._currentSliderValue.toStringAsFixed(0); _errorText = null; }); }, @@ -65,7 +65,7 @@ class SliderState extends State { onChanged: (text) { if (text.isEmpty) { setState(() { - _currentSliderValue = 1; + widget._currentSliderValue = 1; _textFieldController.clear(); _errorText = null; }); @@ -80,7 +80,7 @@ class SliderState extends State { return; } setState(() { - _currentSliderValue = value; + widget._currentSliderValue = value; _errorText = null; }); },