use int for slider value in form, save model on form complete

main
Julian Gegner 2023-02-25 18:54:54 +01:00
parent abbbc4a8c4
commit 265e174889
2 changed files with 11 additions and 6 deletions

View File

@ -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();
}

View File

@ -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();
}
}