flutter_secure_storage 3.2.1+1

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 #

// 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

[3.2.1]

[3.2.0]

  • 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.

[3.1.3]

  • Fix Android 9.0 Pie KeyStore exception. Thanks hacker1024

[3.1.2]

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

[3.1.1]

  • Suppress warning about unchecked operations when compiling for Android.

[3.1.0]

  • Added readAll and deleteAll.

[3.0.0]

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

[2.0.0]````

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

[1.0.0]

  • Bump version

[0.0.1]

  • Initial release

example/README.md

flutter_secure_storage_example #

Demonstrates how to use the flutter_secure_storage plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_secure_storage: ^3.2.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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
99
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
97
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (meta).

Dependencies

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