You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.5, on macOS 15.1.1 24B91 darwin-arm64, locale en-VN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
[✓] Connected device (6 available)
! Error: Browsing on the local area network for iPad Gen 9. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• No issues found!
Code sample
import'package:flutter/material.dart';
import'package:reactive_forms/reactive_forms.dart';
classTestWidgetextendsStatefulWidget {
@override_TestWidgetStatecreateState() =>_TestWidgetState();
}
class_TestWidgetStateextendsState<TestWidget> {
// Initialize the form group with a form arrayfinalFormGroup form =FormGroup({
'elements':FormArray<String>([]),
});
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
appBar:AppBar(
title:constText('Test Widget'),
),
body:Padding(
padding:constEdgeInsets.all(16.0),
child:ReactiveForm(
formGroup: form,
child:Column(
children: [
// Render each element in the FormArray as a TextFormFieldReactiveFormArray(
formArrayName:'elements',
builder: (context, formArray, child) {
returnColumn(
children: [
for (int i =0; i < formArray.controls.length; i++)
Row(
children: [
Expanded(
child:ReactiveTextField<String>(
formControlName: i.toString(),
decoration:constInputDecoration(
labelText:'Element',
),
),
),
IconButton(
icon:constIcon(Icons.delete),
onPressed: () {
(formArray asFormArray<String>).removeAt(i);
},
),
],
),
],
);
},
),
constSizedBox(height:16.0),
ElevatedButton(
onPressed: () {
// Add a new element to the FormArray
(form.control('elements') asFormArray<String>).add(
FormControl<String>(),
);
},
child:constText('Add Element'),
),
],
),
),
),
);
}
}
voidmain() =>runApp(MaterialApp(home:TestWidget()));
Description
Adding 3 text fields, input different values for each of them. For example: 1, 2, 3
Expected behavior: When press remove button of (2), expect that the second element will be removed
Current behavior: The last element always be removed. The array length has been updated but the formArray value still be the same.
Steps to reproduce
Add 3 elements
Input different value for each element
Remove the first or second element
Images
Stacktrace/Logcat
The text was updated successfully, but these errors were encountered:
Environment
Package version: 17.0.x
Flutter doctor
Code sample
Description
Adding 3 text fields, input different values for each of them. For example: 1, 2, 3
Expected behavior: When press remove button of (2), expect that the second element will be removed
Current behavior: The last element always be removed. The array length has been updated but the formArray value still be the same.
Steps to reproduce
Images
Stacktrace/Logcat
The text was updated successfully, but these errors were encountered: