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() {
|
void submitForm() {
|
||||||
if (_moodFormKey.currentState!.validate()) {
|
if (_moodFormKey.currentState!.validate()) {
|
||||||
_moodFormKey.currentState?.save(); //call every onSave Method
|
_moodFormKey.currentState?.save(); //call every onSave Method
|
||||||
Mood mood = Mood(slider.getSliderValue(), _textInput, DateTime.now());
|
Mood mood =
|
||||||
print(mood.toCSV());
|
Mood(slider.getSliderValue().toInt(), _textInput, DateTime.now());
|
||||||
DatabaseService.instance.addMood(mood);
|
DatabaseService.instance.addMood(mood);
|
||||||
_moodFormKey.currentState?.reset();
|
_moodFormKey.currentState?.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
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/elevated_card.dart';
|
||||||
import 'package:smoke_cess_app/widgets/slider.dart';
|
import 'package:smoke_cess_app/widgets/slider.dart';
|
||||||
import 'package:smoke_cess_app/widgets/submit_form_button.dart';
|
import 'package:smoke_cess_app/widgets/submit_form_button.dart';
|
||||||
|
@ -26,10 +28,13 @@ class _SleepFormState extends State<SleepForm> {
|
||||||
void submitForm() {
|
void submitForm() {
|
||||||
if (_sleepFormKey.currentState!.validate()) {
|
if (_sleepFormKey.currentState!.validate()) {
|
||||||
_sleepFormKey.currentState?.save(); //call every onSave Method
|
_sleepFormKey.currentState?.save(); //call every onSave Method
|
||||||
//TODO Businesslogik aufrufen!
|
Sleep sleep = Sleep(
|
||||||
print(_textInput);
|
slider.getSliderValue().toInt(),
|
||||||
print(slider.getSliderValue());
|
_textInput,
|
||||||
print('Eingeschlafen um: ${sleepTimePicker.getCurrentTime}');
|
DateTime.now(),
|
||||||
|
sleepTimePicker.getCurrentTime,
|
||||||
|
wakeUpTimePicker.getCurrentTime);
|
||||||
|
DatabaseService.instance.addSleep(sleep);
|
||||||
_sleepFormKey.currentState?.reset();
|
_sleepFormKey.currentState?.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue