single form

This commit is contained in:
Jorian van der Kolk 2022-10-25 16:45:07 +02:00
parent 9827555723
commit 97e516a5b7
2 changed files with 6 additions and 15 deletions

View file

@ -8,6 +8,7 @@ class ItemList extends StatefulWidget {
this.typeMap,
this.spacing,
this.updateProfile, {
required this.formKey,
this.itemBuilder,
this.itemBuilderOptions,
super.key,
@ -19,25 +20,13 @@ class ItemList extends StatefulWidget {
final Function(String, String) updateProfile;
final ItemBuilder? itemBuilder;
final ItemBuilderOptions? itemBuilderOptions;
final GlobalKey<FormState> formKey;
@override
State<ItemList> createState() => _ItemListState();
}
class _ItemListState extends State<ItemList> {
Map<String, GlobalKey<FormState>> formKeys = {};
@override
void initState() {
super.initState();
for (var item in widget.items.entries) {
formKeys.addAll(
{item.key: GlobalKey<FormState>()},
);
}
}
@override
Widget build(BuildContext context) {
var widgets = <Widget>[];
@ -49,7 +38,7 @@ class _ItemListState extends State<ItemList> {
? widgets.add(
builder.build(
item.key,
formKeys['item.key'] ?? GlobalKey<FormState>(),
widget.formKey,
item.value,
widget.typeMap[item.key],
(value) {
@ -60,7 +49,7 @@ class _ItemListState extends State<ItemList> {
: widgets.add(
widget.itemBuilder!.build(
item.key,
formKeys['item.key'] ?? GlobalKey<FormState>(),
widget.formKey,
item.value,
widget.typeMap[item.key],
(value) {

View file

@ -151,6 +151,7 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
},
itemBuilder: widget.itemBuilder,
itemBuilderOptions: widget.itemBuilderOptions,
formKey: formKey,
),
if (widget.showDefaultItems) ...defaultItems,
// remove all the items that have priority from the widget.user.profileData!.toMap()
@ -169,6 +170,7 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
},
itemBuilder: widget.itemBuilder,
itemBuilderOptions: widget.itemBuilderOptions,
formKey: formKey,
),
],
);