Search packages, repositories and app categories

Package detailsv1.0.5

get_secure_storage

A secure version of get_storage, which was a fast, extra light and synchronous key-value storage written entirely in Dart

AndroidiOSWebmacOSWindowsLinux
30-day downloads
1.5K
Likes
29
Pub points
130

Install package

flutter pub add get_secure_storage

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

GetSecureStorage is a secure, synchronous key-value storage solution built on top of GetStorage, designed for Dart applications. It provides encrypted data persistence across multiple platforms including Android, iOS, Web, macOS, Windows, and Linux. Unlike standard storage, it safeguards sensitive information by encrypting values before saving them, making it ideal for storing credentials, tokens, or private user data. The package maintains the lightweight and fast performance of its predecessor while adding robust security features.

Use cases

  • Storing user authentication tokens
  • Saving encrypted API keys
  • Persisting sensitive user preferences
  • Securing session data
  • Protecting login credentials
  • Enabling secure offline data storage

Key features

  • End-to-end encryption of stored data
  • Synchronous API for predictable execution
  • Cross-platform compatibility
  • Lightweight and fast performance
  • Simple key-value interface
  • Built on top of GetStorage

Suitable for

  • Apps requiring secure data persistence
  • Developers prioritizing simplicity and speed
  • Projects handling sensitive user information
  • Mobile and desktop applications with offline needs
  • Teams using Flutter with minimal dependencies

Considerations

  • Not suitable for large datasets
  • Encryption adds minor performance overhead
  • Requires careful key management
  • Limited to basic key-value operations
  • No built-in data migration support
  • Depends on underlying GetStorage implementation

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

get_secure_storage

A cryptography Secure version of GetStorage originally written by Jonny Borges (https://github.com/jonataslaw/get_storage).

GetSecureStorage is a secure, fast, extra light and synchronous key-value in memory, which backs up data to disk at each operation. It is written entirely in Dart and is based on the Cryptography dart package.

The cryptography library used is https://pub.dev/packages/cryptography

The algorithm used is 128bit AES-CTR with MAC sha256

Supports Android, iOS, Web, Mac, Linux, and Windows. Can store String, int, double, Map and List

Add to your pubspec:
dependencies:
  get_secure_storage:
Install it

You can install packages from the command line:

with Flutter:

$  flutter packages get
Import it

Now in your Dart code, you can use:

import 'package:get_secure_storage/get_secure_storage.dart';
Initialize storage driver with await:
main() async {
  await GetSecureStorage.init(password: 'strongpassword');
  runApp(App());
}
use GetSecureStorage through an instance or use directly GetSecureStorage().read('key')
final box = GetSecureStorage(password: 'strongpassword');
To write information you must use write :
box.write('quote', 'GetSecureStorage is the best');
To read values you use read:
print(box.read('quote'));
// out: GetSecureStorage is the best

To remove a key, you can use remove:
box.remove('quote');
To listen changes you can use listen:
Function? disposeListen;
disposeListen = box.listen((){
  print('box changed');
});
If you subscribe to events, be sure to dispose them when using:
disposeListen?.call();
To listen changes on key you can use listenKey:
box.listenKey('key', (value){
  print('new key is $value');
});
To erase your container:
box.erase();
If you want to create different containers, simply give it a name. You can listen to specific containers, and also delete them.
GetSecureStorage g = GetSecureStorage(container:'MyStorage', password: 'strongpassword');
To initialize specific container:
await GetSecureStorage.init(container:'MyStorage', password: 'strongpassword');

SharedPreferences Implementation

class MyPref {
  static final _otherBox = () => GetSecureStorage(container:'MyPref', password: 'strongpassword');

  final username = ''.val('username');
  final age = 0.val('age');
  final price = 1000.val('price', getBox: _otherBox);

  // or
  final username2 = ReadWriteValue('username', '');
  final age2 = ReadWriteValue('age', 0);
  final price2 = ReadWriteValue('price', '', _otherBox);
}

...

void updateAge() {
  final age = 0.val('age');
  // or 
  final age = ReadWriteValue('age', 0, () => box);
  // or 
  final age = Get.find<MyPref>().age;

  age.val = 1; // will save to box
  final realAge = age.val; // will read from box
}

Categories

Dependencies

Dependency list 3 items

Source repository

Projects using this package

No data available yet.