native_storage 0.1.5 copy "native_storage: ^0.1.5" to clipboard
native_storage: ^0.1.5 copied to clipboard

A Dart-only package for accessing platform-native storage functionality.

example/lib/main.dart

import 'package:native_storage/native_storage.dart';

Future<void> main() async {
  // Native storage is a simple key-value store that can be used to store
  // data on the device. It has three variations: local, secure, and isolated.
  final storage = NativeStorage();
  storage.write('key', 'value');
  print('Value from local storage: ${storage.read('key')}');

  // To create a secure variation of `storage`, use the `secure` getter.
  final secureStorage = storage.secure;

  // Reading the same key should print `null` since secure values are stored
  // separate from the local storage.
  print('Value from secure storage: ${secureStorage.read('key')}');

  secureStorage.write('key', 'value1');
  print('Value from secure storage: ${secureStorage.read('key')}');

  // Typically, though, you should use the `isolated` variation of both
  // local and secure storage so that you never block the UI thread when
  // reading or writing to storage.
  final isolatedStorage = storage.isolated;
  final isolatedRead = await isolatedStorage.read('key');
  print('Value from isolated local storage: $isolatedRead');

  final isolatedSecureStorage = secureStorage.isolated;
  final isolatedSecureRead = await isolatedSecureStorage.read('key');
  print('Value from isolated secure storage: $isolatedSecureRead');
}
44
likes
140
pub points
49%
popularity

Publisher

verified publishercelest.dev

A Dart-only package for accessing platform-native storage functionality.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause-Patent (LICENSE)

Dependencies

ffi, jni, logging, meta, path, stack_trace, stream_channel, web, win32, win32_registry, windows_applicationmodel, xdg_directories

More

Packages that depend on native_storage