diff --git a/lib/src/form/src/controller.dart b/lib/src/form/src/controller.dart index cc88a76..e082766 100644 --- a/lib/src/form/src/controller.dart +++ b/lib/src/form/src/controller.dart @@ -275,6 +275,7 @@ class AstromicFormController extends FormController { if (groupStructure.values != null && groupStructure.values!.isNotEmpty) { for (String valueID in groupStructure.values!) { removeController('${groupStructure.id}-#$indexToRemove-$valueID'); + _hostedValues.remove('${groupStructure.id}-#$indexToRemove-$valueID'); } } } else { @@ -286,11 +287,16 @@ class AstromicFormController extends FormController { } if (groupStructure.values != null && groupStructure.values!.isNotEmpty) { for (String valueID in groupStructure.values!) { + _hostedValues.remove('${groupStructure.id}-#$indexToRemove-$valueID'); set('${groupStructure.id}-#$indexToRemove-$valueID', value('${groupStructure.id}-#$nextIndex-$valueID')); + setValue('${groupStructure.id}-#$indexToRemove-$valueID', getValue('${groupStructure.id}-#$nextIndex-$valueID')); removeController('${groupStructure.id}-#$nextIndex-$valueID'); + _hostedValues.remove('${groupStructure.id}-#$nextIndex-$valueID'); } } } + // Remove last instance + } } diff --git a/lib/src/form/src/form_group_wrapper.dart b/lib/src/form/src/form_group_wrapper.dart index d572cff..c1cef49 100644 --- a/lib/src/form/src/form_group_wrapper.dart +++ b/lib/src/form/src/form_group_wrapper.dart @@ -131,6 +131,7 @@ class _FormGroupWrapperState extends State { void _removeItem(int i) { setState(() { widget.formController.removeInstanceFromFormGroup(widget.groupID, i); + instances = widget.formController.getFormGroupValue(widget.groupID)!.instances; }); }