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