Skip to content
pubscout

encrypt_shared_preferences

1.0.1, released 8 months ago by an unverified publisher

AES encrypted wrapper for shared_preferences to securely store sensitive data.

WASM-readyUnverified publisher
$ flutter pub add encrypt_shared_preferences
Source repository

What it does

Adds an extra layer of AES encryption to key-value data saved via shared_preferences. It supports various data types, stream-based observers for key changes, and a custom encryptor interface.

AI-written summary of version 1.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to store encrypted simple key-value data on device
  • You want a drop-in replacement or wrapper over shared_preferences with encryption

Skip it when

  • You need robust, platform-backed secure storage like Keychain or Keystore directly without a custom password key

Strengths

  • Supports multiple data types including strings, numbers, booleans, and lists
  • Includes stream observers and widgets to react to storage changes
  • Allows custom external encryptors

Weaknesses

  • Relies on a user-provided encryption key which must be managed securely
  • Plain shared_preferences underlying storage can still be accessed if the key is compromised

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
3
void main() async {
  final key = "";
  await EncryptedSharedPreferences.initialize(key: key);
  var sharedPref = EncryptedSharedPreferences.getInstance();
  await sharedPref.setString('user_token', 'xxxxxxxxxxxx');
  sharedPref.getString('user_token');
}

Alternatives

Packages that do the same job and could replace encrypt_shared_preferences.

  • flutter_secure_storage

    Uses platform-native secure storage mechanisms (Keychain/EncryptedSharedPreferences) natively instead of manual AES wrappers over plain shared preferences.

Works with

Packages commonly used together with encrypt_shared_preferences: ones it builds on, ones built on it, and its own family.