From 30cf45bd3525689ce7d21fb6e14f3cb367ff3361 Mon Sep 17 00:00:00 2001 From: bogdan <1926167@stud.hs-mannheim.de> Date: Sat, 3 Jun 2023 01:06:38 +0200 Subject: [PATCH] bug --- lib/android/components/form/form_builder.dart | 25 +++++++++++++------ .../form_builder_text_field_component.dart | 4 ++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/android/components/form/form_builder.dart b/lib/android/components/form/form_builder.dart index 10e086e..d79d85f 100644 --- a/lib/android/components/form/form_builder.dart +++ b/lib/android/components/form/form_builder.dart @@ -118,19 +118,30 @@ class _FormBuilderComponentState extends State { ), onPressed: () { final Box box = Hive.box("USER_BOX"); + + print(formKey + .currentState?.fields['gewicht']?.value ?? + box.get("USER").gewicht); + box.put( "USER", User( - formKey.currentState?.fields['vorname']?.value, - formKey.currentState?.fields['nachname']?.value, + formKey.currentState?.fields['vorname']?.value.toString() ?? + box.get("USER").vorname.toString(), + formKey.currentState?.fields['nachname']?.value.toString() ?? + box.get("USER").nachname.toString(), int.parse(formKey - .currentState?.fields['gewicht']?.value), + .currentState?.fields['gewicht']?.value ?? + box.get("USER").gewicht), int.parse(formKey - .currentState?.fields['groesse']?.value), - int.parse( - formKey.currentState?.fields['alter']?.value), + .currentState?.fields['groesse']?.value ?? + int.parse(box.get("USER").groesse)), int.parse(formKey - .currentState?.fields['kalorien']?.value))); + .currentState?.fields['alter']?.value ?? + int.parse(box.get("USER").alter)), + int.parse(formKey.currentState?.fields['kalorien'] + ?.value ?? + int.parse(box.get("USER").kalorien)))); Navigator.of(context).pushReplacement(MaterialPageRoute( builder: (BuildContext context) => const MainPage())); diff --git a/lib/android/components/form/form_builder_text_field_component.dart b/lib/android/components/form/form_builder_text_field_component.dart index 1c18a35..36a201b 100644 --- a/lib/android/components/form/form_builder_text_field_component.dart +++ b/lib/android/components/form/form_builder_text_field_component.dart @@ -75,16 +75,18 @@ class TextFieldChild extends StatelessWidget { hintText: StringUtils.capitalize(formTextField.title), labelText: StringUtils.capitalize(formTextField.title), fillColor: Colors.white70), - keyboardType: TextInputType.number, + keyboardType: formTextField.textInputType, maxLength: TextInputType.number == formTextField.textInputType ? 7 : 30, autovalidateMode: AutovalidateMode.onUserInteraction, validator: FormBuilderValidators.compose([ FormBuilderValidators.required(), + TextInputType.number == formTextField.textInputType ? FormBuilderValidators.max(formTextField.numericMax!, errorText: formTextField.numericMaxErrorMessage) : FormBuilderValidators.maxLength(30, errorText: formTextField.maxLengthErrorMessage), + TextInputType.number == formTextField.textInputType ? FormBuilderValidators.min(formTextField.numericMin!, errorText: formTextField.numericMinErrorMessage)