skip to Main Content

I basically have 2 main screens in my app:

  1. main menu – it contains all the pages of my app and i can navigate too those pages from here.
  2. main menu item page – this page contains dynamic multi-forms.
    When i create multiple forms and fill input in text fields and press save i want to save the data of multiple forms so i can use that somewhere else,
    and when i go back to main menu and come again to menu item page i want all the forms and that data to be there in text fields.
    my problem is when i go back and come again to menu item page, all multiform are lost and all the data is also lost.

enter image description here
enter image description here
enter image description here

if the form is saved then after navigating to different pages the forms and data should remain on the page.

3

Answers


  1. You can use one of many data storing methods.

    • You can save to database such as mySql
    • You can save to a json file
    • You can use the shared_preferences package
    • Hive database
    Login or Signup to reply.
  2. The best way is to locally store the data using shared preference

    // Pass your controller.text here
    saveToPhone(String name) async {
        SharedPreferences preferences = await SharedPreferences.getInstance();
        try {
          preferences.setString('name', name);
        } catch (e) {
          print(e.toString());
        }
      }
     
    // Get your data while your app opens using this function
      getFromPhone() async {
        SharedPreferences preferences = await SharedPreferences.getInstance();
        try {
          return preferences.getString('name');
     
        } catch (e) {
          print(e.toString());
        }
      }
    
    

    Find the complete example of the above here

    Login or Signup to reply.
  3. Create a model class of form,
    on click event of save

    • you can store value using controller to model class and then access
      it on another screen
      OR
    • save data in local database SQLite
    • shared_pref
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search