Bogdan Kotikov 2023-06-03 01:06:38 +02:00
parent ca5f610dcb
commit 30cf45bd35
2 changed files with 21 additions and 8 deletions

View File

@ -118,19 +118,30 @@ class _FormBuilderComponentState extends State<FormBuilderComponent> {
), ),
onPressed: () { onPressed: () {
final Box box = Hive.box<User>("USER_BOX"); final Box box = Hive.box<User>("USER_BOX");
print(formKey
.currentState?.fields['gewicht']?.value ??
box.get("USER").gewicht);
box.put( box.put(
"USER", "USER",
User( User(
formKey.currentState?.fields['vorname']?.value, formKey.currentState?.fields['vorname']?.value.toString() ??
formKey.currentState?.fields['nachname']?.value, box.get("USER").vorname.toString(),
formKey.currentState?.fields['nachname']?.value.toString() ??
box.get("USER").nachname.toString(),
int.parse(formKey int.parse(formKey
.currentState?.fields['gewicht']?.value), .currentState?.fields['gewicht']?.value ??
box.get("USER").gewicht),
int.parse(formKey int.parse(formKey
.currentState?.fields['groesse']?.value), .currentState?.fields['groesse']?.value ??
int.parse( int.parse(box.get("USER").groesse)),
formKey.currentState?.fields['alter']?.value),
int.parse(formKey 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( Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (BuildContext context) => const MainPage())); builder: (BuildContext context) => const MainPage()));

View File

@ -75,16 +75,18 @@ class TextFieldChild extends StatelessWidget {
hintText: StringUtils.capitalize(formTextField.title), hintText: StringUtils.capitalize(formTextField.title),
labelText: StringUtils.capitalize(formTextField.title), labelText: StringUtils.capitalize(formTextField.title),
fillColor: Colors.white70), fillColor: Colors.white70),
keyboardType: TextInputType.number, keyboardType: formTextField.textInputType,
maxLength: TextInputType.number == formTextField.textInputType ? 7 : 30, maxLength: TextInputType.number == formTextField.textInputType ? 7 : 30,
autovalidateMode: AutovalidateMode.onUserInteraction, autovalidateMode: AutovalidateMode.onUserInteraction,
validator: FormBuilderValidators.compose([ validator: FormBuilderValidators.compose([
FormBuilderValidators.required(), FormBuilderValidators.required(),
TextInputType.number == formTextField.textInputType TextInputType.number == formTextField.textInputType
? FormBuilderValidators.max(formTextField.numericMax!, ? FormBuilderValidators.max(formTextField.numericMax!,
errorText: formTextField.numericMaxErrorMessage) errorText: formTextField.numericMaxErrorMessage)
: FormBuilderValidators.maxLength(30, : FormBuilderValidators.maxLength(30,
errorText: formTextField.maxLengthErrorMessage), errorText: formTextField.maxLengthErrorMessage),
TextInputType.number == formTextField.textInputType TextInputType.number == formTextField.textInputType
? FormBuilderValidators.min(formTextField.numericMin!, ? FormBuilderValidators.min(formTextField.numericMin!,
errorText: formTextField.numericMinErrorMessage) errorText: formTextField.numericMinErrorMessage)