use int for slider value in form, save model on form complete
parent
abbbc4a8c4
commit
265e174889
|
@ -22,8 +22,8 @@ class _MoodFormState extends State<MoodForm> {
|
|||
void submitForm() {
|
||||
if (_moodFormKey.currentState!.validate()) {
|
||||
_moodFormKey.currentState?.save(); //call every onSave Method
|
||||
Mood mood = Mood(slider.getSliderValue(), _textInput, DateTime.now());
|
||||
print(mood.toCSV());
|
||||
Mood mood =
|
||||
Mood(slider.getSliderValue().toInt(), _textInput, DateTime.now());
|
||||
DatabaseService.instance.addMood(mood);
|
||||
_moodFormKey.currentState?.reset();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:smoke_cess_app/models/sleep.dart';
|
||||
import 'package:smoke_cess_app/service/database_service.dart';
|
||||
import 'package:smoke_cess_app/widgets/elevated_card.dart';
|
||||
import 'package:smoke_cess_app/widgets/slider.dart';
|
||||
import 'package:smoke_cess_app/widgets/submit_form_button.dart';
|
||||
|
@ -26,10 +28,13 @@ class _SleepFormState extends State<SleepForm> {
|
|||
void submitForm() {
|
||||
if (_sleepFormKey.currentState!.validate()) {
|
||||
_sleepFormKey.currentState?.save(); //call every onSave Method
|
||||
//TODO Businesslogik aufrufen!
|
||||
print(_textInput);
|
||||
print(slider.getSliderValue());
|
||||
print('Eingeschlafen um: ${sleepTimePicker.getCurrentTime}');
|
||||
Sleep sleep = Sleep(
|
||||
slider.getSliderValue().toInt(),
|
||||
_textInput,
|
||||
DateTime.now(),
|
||||
sleepTimePicker.getCurrentTime,
|
||||
wakeUpTimePicker.getCurrentTime);
|
||||
DatabaseService.instance.addSleep(sleep);
|
||||
_sleepFormKey.currentState?.reset();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue