safe_local_storage 1.0.2 copy "safe_local_storage: ^1.0.2" to clipboard
safe_local_storage: ^1.0.2 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',
  );
}
8
likes
130
pub points
78%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

path, synchronized

More

Packages that depend on safe_local_storage