flutter_secure_storage 3.3.1+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 99

flutter_secure_storage #

A Flutter plugin to store data in secure storage:

  • Keychain is used for iOS
  • AES encryption is used for Android. AES secret key is encrypted with RSA and RSA key is stored in KeyStore

Note KeyStore was introduced in Android 4.3 (API level 18). The plugin wouldn't work for earlier versions.

Getting Started #

import 'package:flutter_secure_storage/flutter_secure_storage.dart';

// Create storage
final storage = new FlutterSecureStorage();

// Read value 
String value = await storage.read(key: key);

// Read all values
Map<String, String> allValues = await storage.readAll();

// Delete value 
await storage.delete(key: key);

// Delete all 
await storage.deleteAll();

// Write value 
await storage.write(key: key, value: value);

Configure Android version #

In [project]/android/app/build.gradle set minSdkVersion to >= 18.

android {
    defaultConfig {
        minSdkVersion 18


Note By default Android backups data on Google Drive. It can cause exception java.security.InvalidKeyException:Failed to unwrap key. You need to

Integration Tests #

Run the following command from example directory

flutter drive --target=test_driver/app.dart




  • Added groupId for iOS keychain sharing. Thanks Maleandr.
  • Fix Gradle version in gradle-wrapper.properties. Thanks blasten.
  • Added minimum sdk requirement on AndroidManifest. Thanks lidongze91.



  • Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library. Thanks I-am-original.
  • Enable StrongBox on Android devices that support it. Thanks bbedward.


  • Fix Android 9.0 Pie KeyStore exception. Thanks hacker1024


  • Added recreating secretKey if its decoding failed. Fix for unwrap key. Thanks hnvn.


  • Suppress warning about unchecked operations when compiling for Android.


  • Added readAll and deleteAll.


  • Breaking change. Changed payloads encryption for Android from RSA to AES, AES secret key is encrypted with RSA.


  • Breaking change. Changed key alias to fix Android 4.4.2 issue. The plugin isn't able to get previous stored data.


  • Bump version


  • Initial release


flutter_secure_storage_example #

Demonstrates how to use the flutter_secure_storage plugin.

Integration Tests #

Run the following command

flutter drive --target=test_driver/app.dart

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_secure_storage: ^3.3.1+1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_secure_storage/flutter_secure_storage.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Fix lib/flutter_secure_storage.dart. (-0.50 points)

Analysis of lib/flutter_secure_storage.dart reported 1 hint:

line 74 col 7: Name types using UpperCamelCase.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
meta ^1.1.2 1.1.8
Transitive dependencies
collection 1.14.11 1.14.12
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8