Flutter Shared Preferences

Mobile Apps Development A-Z Guide.

Volodymyr Babenko
Pharos Production
3 min readApr 3, 2019

--

Give us a message if you’re interested in Blockchain and FinTech software development or just say Hi at Pharos Production Inc.

Or follow us on Youtube to know more about Software Architecture, Distributed Systems, Blockchain, High-load Systems, Microservices, and Enterprise Design Patterns.

Pharos Production Youtube channel

Absolutely any mobile application needs data storage. Information about the user, and so to say the main data such as posts, purchases, orders, and similar should be stored in a database.
But the application settings — it is best to store in the key-value storage. So let’s implement local storage in our Flutter application.

Step1. Create a new application. And add the following dependency to pubspec.yaml. The latest version on this moment is 0.5.1+1:

Step2. Create a class that will contain the static functions of reading and writing to preference:

Step3. A little running ahead, let’s create a class that will consist of constant variables.

Step 4. This class combines a class with constant variables and a helper class for writing and reading primitive data.

Step5. It remains the simplest. Making a simple screen with four widgets. Two buttons and text and text field:

An example of code you can find on the link below:

Thanks for reading!

--

--