Shared preferences are used to store the small amount of data like some intdoublebool or string value in the local memory. Let me take a simple use case of it for your better understanding.

Keep the user logged in using shared preferences

This is one of the best use cases of shared preferences. Once the user gives the correct id and password then we save a bool value equal to true in local memory. Let’s say isUserLoggedIn = true.

Now you can check the value of isUserLoggedIn whenever the user starts the app and based on the value you can show the login screen or main dashboard directly.

What we are going to build?

To demonstrate the use of shared preferences in Flutter we will develop a simple app in which you can increase or decrease the number shown in the text filed with the help of these two buttons.

Once you set the desired value then you can terminate the app and restart it again. You will find the same value in the text field because of shared preferences.

#flutter

How to Save and Read Data from Shared Preferences in Flutter
9.55 GEEK