webstorage 1.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 80

Web Storage for Dart #

Runtime Release License Build

Services for interacting with the Web Storage, in Dart.

Documentation #

Development #

License #

Web Storage for Dart is distributed under the MIT License.

Changelog #

Version 1.1.0

  • Raised the Dart SDK constraint.
  • Updated the package dependencies.

Version 1.0.0 #

  • Initial release.

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();
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  webstorage: ^1.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:webstorage/webstorage.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
61
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Jan 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Fix lib/src/storage.dart. (-0.50 points)

Analysis of lib/src/storage.dart reported 1 hint:

line 60 col 7: DO use curly braces for all flow control structures.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
json_annotation ^3.0.0 3.0.1
Dev dependencies
build_runner ^1.7.2
build_test ^0.10.10
build_web_compilers ^2.7.1
grinder ^0.8.3
json_serializable ^3.2.3
test ^1.9.4