webstorage 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

Web Storage for Dart #

Runtime Release License Build

Services for interacting with the Web Storage.

Documentation #

Development #

License #

Web Storage for Dart is distributed under the MIT License.

Changelog #

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.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support 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]
0
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]
50
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: web

Primary library: package:webstorage/webstorage.dart with components: html.

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.5.0 <3.0.0
json_annotation ^3.0.0 3.0.0
Dev dependencies
build_runner ^1.7.1
build_test ^0.10.9
build_web_compilers ^2.6.2
grinder ^0.8.3
json_serializable ^3.2.2
test ^1.8.0