Using secure storage to store data
- A very common task for apps is storing user credentials, or other sensitive data, within the app itself.
SharedPreferences
is not an ideal tool to perform this task as data cannot be encrypted. In this recipe, you will learn how to store encrypted data usingflutter_secure_storage
, which provides an easy and secure way to store data.
Getting ready
To follow along with this recipe, you will need to do the following:
- If you are using Android, you need to set the
compileSdkVersion
in your app'sbuild.gradle
file to33
. The file is located in your project folder, in/android/app/build.gradle
. ThecompileSdkVersion
key must be set in thedefaultConfig
node, like this:
compileSdkVersion 33
- Download the starting code for this app, which is available at https://github.com/PacktPublishing/Flutter-Cookbook/tree/master/chapter_08.
How to do it...
For this recipe, we will create an app that takes a String
from a text field and stores it securely...