Issue
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
Solution
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()
];
Answered By - Igor Kharakhordin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.