encrypted_shared_preferences 1.0.7
encrypted_shared_preferences: ^1.0.7

Flutter Android iOS

This plugin stores Shared Preferences as encrypted values on device storage.

Encrypted Shared Preferences #

Pub

This plugin stores Shared Preferences as encrypted values. It is decrypted when retrieved. You could use this side by side with regular Shared Preferences. Make sure to target iOS 9.0 and later if you're going to deploy for iOS.

Usage #

Instantiate class: #

EncryptedSharedPreferences encryptedSharedPreferences = EncryptedSharedPreferences();

Save value: #

encryptedSharedPreferences.setString('sample', 'Hello, World!').then((bool success) {
    if (success) {
        print('success');
    } else {
        print('fail');
    }
});

Retrieve value: #

encryptedSharedPreferences.getString('sample').then((String value) {
    print(value); /// Prints Hello, World!
});

Clear values: #

/// Clears all values, including those you saved using regular Shared Preferences.
encryptedSharedPreferences.clear().then((bool success) {
    if (success) {
        print('success');
    } else {
        print('fail');
    }
});

Reload #

encryptedSharedPreferences.reload();

Optional: Pass custom SharedPreferences instance #

/// You can pass a custom SharedPreferences instance (e.g. A newer version of SharedPreferences)
final prefs = await SharedPreferences.getInstance();
EncryptedSharedPreferences encryptedSharedPreferences = EncryptedSharedPreferences(prefs: prefs);

Access internal SharedPreferences instance #

// You can access the internal SharedPreferences instance to invoke methods not exposed by regular EncryptedSharedPreferences
SharedPreferences instance = await encryptedSharedPreferences.getInstance();
int counter = 1;

/// Access SharedPreferences' setInt method
await instance.setInt('counter', counter);
12
likes
90
pub points
83%
popularity

This plugin stores Shared Preferences as encrypted values on device storage.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

rockinroull@gmail.com

License

GPL 2.0 (LICENSE)

Dependencies

flutter, flutter_string_encryption, shared_preferences

More

Packages that depend on encrypted_shared_preferences