0

I'm trying to have the user put information in a TextField on one screen and then save that info when they press "Save". Then I want this text to show up on another screen in another Container (say it asks for their name, they put it in the TextField, press the Button called "Save", it takes them back to the other screen, and the box that previously said "Name" now says "[The name the user entered]").

Thank you in advance for any help!!

emma
  • 1

2 Answers2

1

Use StateManagement Libraries like flutter_bloc,provider,mobx, getX.

This way you will be able to save your data and use in in any part of your app

0

There are multiple ways of going about doing this.

  1. You can pass the value through the constructors of the screens you're navigating to (for e.g.
MaterialPageRoute(builder: (context) => NewPage(name: nameValue))
  1. If you want to use this value in multiple places in your application, you can consider storing it in a config class of sorts (i.e., create a class Config as a singleton (only once instance allowed), and store the name there while saving like Config.name = nameValue. Then, anywhere in your app, you'd access it as Config.name)

  2. If you want this value to be used anywhere else in the app, but also want it to be persistent, then it's probably best to store it as SharedPreferences or in a database. Look into the sharedpreferences package, or sqflite package for Flutter.

Zac
  • 998
  • 6
  • 19