safe_local_storage 1.0.0 copy "safe_local_storage: ^1.0.0" to clipboard
safe_local_storage: ^1.0.0 copied to clipboard

A safe caching library to read/write values on local storage.

example/main.dart

import 'dart:io';

import 'package:path/path.dart';
import 'package:safe_local_storage/safe_local_storage.dart';

Future<void> main() async {
  // Create a [SafeLocalStorage] object, decide where you want to keep your cache.
  final storage = SafeLocalStorage(location);
  // Write your data, will be stored locally.
  await storage.write(
    {
      'foo': 'bar',
    },
  );
  // Perform read.
  final data = await storage.read();
  print(data);
  // {foo: bar}
}

String get location {
  final script = Platform.script.toFilePath();
  final parent = File(script).parent.path;
  return join(
    parent,
    'cache.json',
  );
}
9
likes
0
pub points
79%
popularity

Publisher

unverified uploader

A safe caching library to read/write values on local storage.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

path, synchronized

More

Packages that depend on safe_local_storage