fixed keyboard closing ontap field

This commit is contained in:
Jorian van der Kolk 2022-10-25 09:17:08 +02:00
parent 7c30113d9f
commit e6b1605b89
2 changed files with 19 additions and 24 deletions

View file

@ -23,22 +23,19 @@ class ItemBuilder {
inputDecoration =
options.inputDecorationField?[key] ?? options.inputDecoration;
return Form(
key: formKey,
child: TextFormField(
key: Key(key),
controller: controller,
decoration: inputDecoration,
readOnly: options.readOnly,
onFieldSubmitted: (value) {
if (formKey.currentState!.validate()) {
updateItem(value);
}
},
validator: (value) {
return options.validators?[key]?.call(value);
},
),
return TextFormField(
key: Key(key),
controller: controller,
decoration: inputDecoration,
readOnly: options.readOnly,
onFieldSubmitted: (value) {
if (formKey.currentState!.validate()) {
updateItem(value);
}
},
validator: (value) {
return options.validators?[key]?.call(value);
},
);
}
return widget;

View file

@ -46,9 +46,7 @@ class ProfileWrapper extends StatefulWidget {
class _ProfileWrapperState extends State<ProfileWrapper> {
List<Widget> defaultItems = [];
GlobalKey<FormState> firstNameKey = GlobalKey<FormState>();
GlobalKey<FormState> lastNameKey = GlobalKey<FormState>();
GlobalKey<FormState> formKey = GlobalKey<FormState>();
@override
void initState() {
@ -61,7 +59,7 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
defaultItems.add(
builder.build(
'first_name',
firstNameKey,
formKey,
widget.user.firstName,
null,
(v) {
@ -79,7 +77,7 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
defaultItems.add(
builder.build(
'last_name',
lastNameKey,
formKey,
widget.user.lastName,
null,
(v) {
@ -98,7 +96,7 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
defaultItems.add(
widget.itemBuilder!.build(
'first_name',
firstNameKey,
formKey,
widget.user.firstName,
null,
(v) {
@ -116,7 +114,7 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
defaultItems.add(
widget.itemBuilder!.build(
'last_name',
lastNameKey,
formKey,
widget.user.lastName,
null,
(v) {
@ -197,7 +195,7 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
),
],
// all the items that have priority above the default items
child,
Form(key: formKey, child: child),
if (widget.bottomActionText != null) ...[
SizedBox(
height: widget.style.betweenDefaultItemPadding,