0

I am working on an app in which I have to generate PDF based on user input. but there are more than 60 inputs I need to take from user.

So how can i deal with this ?

A common approach I know is to create TextEditingController for each fields and pass all 60+ field's data in function body to generate PDF, but I have never used 60+ controllers in a single screen so I am confused how to deal with it.

please let me know better way to do this.

1 Answers1

1

If you want to access values within TextFields you have 2 options (afaik):

  1. Create 60 TextEditingController
  2. Create 60 variables (or 1 map, or 1 list), and change these values by taking advantage of the onChange property of the TextField Widget

I would personally go with one map having the field title as a key but this is up to you !

Lulupointu
  • 3,364
  • 1
  • 12
  • 28
  • I am trying 2nd one. I will store data in map as I will be able to fetch data using key (as list data can be accessed using index only, so that will be another mess). – pipaliya ashish Oct 05 '20 at 13:58
  • Glad it works for you. Don't forget to upvote and validate the answers if it solved you issue ! :) – Lulupointu Oct 05 '20 at 14:00
  • well yeah. it's working as expected. [see image](https://pasteboard.co/JukSz9r.png) 1 more question, How can I pass these all user inputs to a function ? – pipaliya ashish Oct 06 '20 at 04:21
  • Just take your map as an argument like: void processUserInputs(Map userInputs) {print("Do something");} – Lulupointu Oct 06 '20 at 06:08