简体   繁体   中英

Best way to save form input in flutter as the user types in

This is an open question for the best practices and experiences with creating forms in flutter. I didn't find a lot of material online, other than basic username and password form.

I was trying to create a screen in flutter that receives user input which is String and double inputs (32 inputs). I have to validate data to make sure numbers are within range, then do calculations and create a detailed PDF report.

My plan was to create a class say InputData where I can store all user inputs, and in my inputScreen create a Form widget with TextFormField s to receive and validate inputs

Expanded MyCustomTextFormField(String labelText, TextInputType textInputType) {
  return Expanded(
        child: TextFormField(
          keyboardType: textInputType,
          maxLines: 2,
          minLines: 1,
          decoration: InputDecoration(
            border: OutlineInputBorder(),
            labelText: labelText,
          ),
        ),
      );
}

How can I store all input data in one InputData class I created as the user types in, and how would I store it on the phone as the user types as well.

Any ideas!

What do you think about using textEditingController?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM