single_item_secure_storage 0.0.1+1 copy "single_item_secure_storage: ^0.0.1+1" to clipboard
single_item_secure_storage: ^0.0.1+1 copied to clipboard

outdated

Keychain/Keystore persistent Storage implementation.

single_item_secure_storage #

Keychain/Keystore persistent Storage implementation.

This package is an addon to the single_item_storage package and offers a Storage implementation using the flutter_secure_storage package and dart JSON converters, json.encode and json.decode, to store items.

Getting started #

Create a new instance by providing fromMap and toMap item converters, itemKey as key for this item in keychain, and an optional secureStore instance.

Storage<User> storage = CachedStorage<User>(SecureStorage(
  itemKey: 'model.user.key',
  fromMap: (map) => User.fromMap(map),
  toMap: (item) => item.toMap(),
));

@JsonSerializable()
class User {
  final String id;
  final String email;

  factory User.fromMap(Map<String, dynamic> json) => _$UserFromJson(json);
  Map<String, dynamic> toMap() => _$UserToJson(this);

  User(this.id, this.email);
}

To store primitive values that don't need a converter use the .primitive named constructor.

/* Supported primitive types: 
 - bool
 - double
 - int
 - String
 */
SecureStorage<int>.primitive(itemKey: 'cow_counter')

If the secureStorage is omitted, then an instance of FlutterSecureStorage is used.

When defining the to/from map converter mind that the map values can only be: number, boolean, string, null, list or a map with string keys as defined in json.encode and json.decode from the dart:convert package.

This example uses json_serializable as Map converter for convenience.

1
likes
0
pub points
72%
popularity

Publisher

unverified uploader

Keychain/Keystore persistent Storage implementation.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, flutter_secure_storage, single_item_storage

More

Packages that depend on single_item_secure_storage