SharedPreferences | Flutter | Dart

Syed Ameenuddin
2 min readJun 18, 2021

Flutter apps have some sort of user state that don’t store data(Changes).if you kills your app your data also killed. So here we have our friend in SharedPreferences. SharedPreferences allows an app to store primitive data in key-value pairs.

This makes it easy for developers to store small bits of important information without needing a storage permission amazing, right?

First Step: Add Shared_Prefernces dependency to your pubspec.yaml

pubspec.yaml

Second Step: import Shared_prefernces to your project

Third Step: Set value that you need to storage in SharedPrefernces

SharedPreferences.setString(‘phoneNumber’, //here you need to set that value that you need to store);

Fourth Step: now you can get that value you stored in ‘PhoneNumber’

Full Code:

So say goodbye to those storage permissions and store your small amount of data in key-value pairs

--

--