Is there a way to permanently change value of an variable in flutter?

Issue

I have a list containing some values. And while using the app users can edit those values. But those changes are temporary. When I run the app again, it reverts back to the old values and not the values that were edited previously.

So is there a way to keep those changes ?

Solution

You can use a package like shared_preferences to store the values of those variables on the device and when the user opens the app again, you can read them instead of initializing them to a fixed value.

Alternatively, if you have a backend with user data you can store it there and read it from there.

Answered By – nvoigt

Answer Checked By – Marilyn (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.