Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: Array of TextEditingController

Tags:

flutter

What is the best way to set an array of TextEditingController in a flutter . I mean I need to get a value array of Textfield(1 to n) value and sent to the server.

Can anyone help how to achieve this?

I tried

for(int i=1;i<75;i++) { 
TextEditingController _controller[i] = TextEditingController(); 
}

Regards, Sathish

like image 372
sathish kumar Avatar asked Jun 05 '26 08:06

sathish kumar


1 Answers

There are plenty of ways to do that

List<TextEditingController> _controller = List.generate(74, (i) => TextEditingController());

or

List<TextEditingController> _controller = [];
for (int i = 1; i < 75; i++) _controller.add(TextEditingController());

or

List<TextEditingController> _controller = [
  for (int i = 1; i < 75; i++)
    TextEditingController()
];
like image 192
Igor Kharakhordin Avatar answered Jun 07 '26 13:06

Igor Kharakhordin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!