Fixed DropDown Bug
parent
36ef18a4f7
commit
606e8c3f19
|
@ -11,22 +11,16 @@ class InputProvider extends ChangeNotifier {
|
|||
'wokeUpAt': const TimeOfDay(hour: 8, minute: 0),
|
||||
'sleptAt': const TimeOfDay(hour: 22, minute: 0),
|
||||
};
|
||||
String _relapseCategory = '';
|
||||
String relapseCategory = '';
|
||||
|
||||
double get sliderValue => _sliderValue;
|
||||
TextEditingController get textController => _textController;
|
||||
String get relapseCategory => _relapseCategory;
|
||||
|
||||
set sliderValue(double newValue) {
|
||||
_sliderValue = newValue;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
set relapseCategory(String newValue) {
|
||||
_relapseCategory = newValue;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
TimeOfDay getTimeEntry(String key) {
|
||||
return _times[key] ?? const TimeOfDay(hour: 12, minute: 0);
|
||||
}
|
||||
|
@ -53,7 +47,7 @@ class InputProvider extends ChangeNotifier {
|
|||
|
||||
Future<int> saveRelapse() {
|
||||
Relapse relapse =
|
||||
Relapse(_relapseCategory, _textController.text, DateTime.now());
|
||||
Relapse(relapseCategory, _textController.text, DateTime.now());
|
||||
_resetFields();
|
||||
return globals.databaseService.addRelapse(relapse);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ class DropDown extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var inputModel = context.watch<InputProvider>();
|
||||
inputModel.relapseCategory = _items.isNotEmpty ? _items[0] : '';
|
||||
return DropdownButtonFormField<String>(
|
||||
value: _items.isEmpty ? null : _items[0],
|
||||
icon: const Icon(Icons.arrow_downward),
|
||||
|
|
Loading…
Reference in New Issue