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: () {
final Box box = Hive.box<User>("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()));

View File

@ -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)