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

discontinued
outdated

Services for interacting with the Web Storage. An event-based API to manage storage changes.

example/main.dart

// ignore_for_file: avoid_print
import 'package:webstorage/webstorage.dart';

/// Tests the cookie service.
void main() {
  final storage = LocalStorage();

  // Query the storage.
  print(storage.containsKey('foo')); // false
  print(storage.containsKey('baz')); // false
  print(storage.isEmpty); // true
  print(storage.keys); // []

  // Write to the storage.
  storage['foo'] = 'bar';
  print(storage.containsKey('foo')); // true
  print(storage.length); // 1
  print(storage.keys); // ["foo"]

  storage.setObject('baz', <String, int>{'qux': 123});
  print(storage.containsKey('baz')); // true
  print(storage.length); // 2
  print(storage.keys); // ["foo", "baz"]

  // Read the storage.
  print(storage['foo'].runtimeType); // "String"
  print(storage['foo']); // "bar"

  print(storage.getObject('baz').runtimeType); // "_JsonMap"
  print(storage.getObject('baz')); // {"qux": 123}
  print(storage.getObject('baz')['qux']); // 123

  // Delete from the storage.
  storage.remove('foo');
  print(storage.containsKey('foo')); // false
  print(storage.length); // 1
  print(storage.keys); // ["baz"]

  storage.clear();
  print(storage.containsKey('baz')); // false
  print(storage.isEmpty); // true
  print(storage.keys); // []

  // Release the event listeners.
  storage.destroy();
}
0
likes
0
pub points
17%
popularity

Publisher

verified publisherbelin.io

Services for interacting with the Web Storage. An event-based API to manage storage changes.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

json_annotation

More

Packages that depend on webstorage