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

discontinued

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 service = LocalStorage();

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

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

	service.setObject("baz", {"qux": 123});
	print(service.containsKey("baz")); // true
	print(service.length); // 2
	print(service.keys); // ["foo", "baz"]

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

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

	// Iterate the storage.
	for (final entry in service.entries) print("${entry.key} => ${entry.value}");

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

	service.clear();
	print(service.containsKey("baz")); // false
	print(service.isEmpty); // true
	print(service.keys); // []

	// Release the event listeners.
	service.destroy();
}
0
likes
20
pub points
23%
popularity

Publisher

verified publisherbelin.io

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

Homepage
Repository
View/report issues

License

unknown (LICENSE)

More

Packages that depend on webstorage