StorageArea class
class StorageArea extends ChromeObject { StorageArea(); StorageArea.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy); /** * Gets one or more items from storage. * * [keys] A single key to get, list of keys to get, or a dictionary specifying * default values (see description of the object). An empty list or object * will return an empty result object. Pass in `null` to get the entire * contents of storage. * * Returns: * Object with items in their key-value mappings. */ Future<Map<String, dynamic>> get([dynamic keys]) { var completer = new ChromeCompleter<Map<String, dynamic>>.oneArg(mapify); jsProxy.callMethod('get', [jsify(keys), completer.callback]); return completer.future; } /** * Gets the amount of space (in bytes) being used by one or more items. * * [keys] A single key or list of keys to get the total usage for. An empty * list will return 0. Pass in `null` to get the total usage of all of * storage. * * Returns: * Amount of space being used in storage, in bytes. */ Future<int> getBytesInUse([dynamic keys]) { var completer = new ChromeCompleter<int>.oneArg(); jsProxy.callMethod('getBytesInUse', [jsify(keys), completer.callback]); return completer.future; } /** * Sets multiple items. * * [items] An object which gives each key/value pair to update storage with. * Any other key/value pairs in storage will not be affected. * * Primitive values such as numbers will serialize as expected. Values with a * `typeof` `"object"` and `"function"` will typically serialize to `{}`, with * the exception of `Array` (serializes as expected), `Date`, and `Regex` * (serialize using their `String` representation). */ Future set(Map<String, dynamic> items) { var completer = new ChromeCompleter.noArgs(); jsProxy.callMethod('set', [jsify(items), completer.callback]); return completer.future; } /** * Removes one or more items from storage. * * [keys] A single key or a list of keys for items to remove. */ Future remove(dynamic keys) { var completer = new ChromeCompleter.noArgs(); jsProxy.callMethod('remove', [jsify(keys), completer.callback]); return completer.future; } /** * Removes all items from storage. */ Future clear() { var completer = new ChromeCompleter.noArgs(); jsProxy.callMethod('clear', [completer.callback]); return completer.future; } }
Extends
ChromeObject > StorageArea
Subclasses
LocalStorageArea, SyncStorageArea
Constructors
new StorageArea() #
Create a new instance of a ChromeObject
, which creates and delegates to
a JsObject proxy.
StorageArea();
new StorageArea.fromProxy(JsObject jsProxy) #
Create a new instance of a ChromeObject
, which delegates to the given
JsObject proxy.
StorageArea.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy);
Properties
Methods
Future clear() #
Removes all items from storage.
Future clear() { var completer = new ChromeCompleter.noArgs(); jsProxy.callMethod('clear', [completer.callback]); return completer.future; }
Future<Map<String, dynamic>> get([keys]) #
Gets one or more items from storage.
keys A single key to get, list of keys to get, or a dictionary specifying
default values (see description of the object). An empty list or object
will return an empty result object. Pass in null
to get the entire
contents of storage.
Returns: Object with items in their key-value mappings.
Future<Map<String, dynamic>> get([dynamic keys]) { var completer = new ChromeCompleter<Map<String, dynamic>>.oneArg(mapify); jsProxy.callMethod('get', [jsify(keys), completer.callback]); return completer.future; }
Future<int> getBytesInUse([keys]) #
Gets the amount of space (in bytes) being used by one or more items.
keys A single key or list of keys to get the total usage for. An empty
list will return 0. Pass in null
to get the total usage of all of
storage.
Returns: Amount of space being used in storage, in bytes.
Future<int> getBytesInUse([dynamic keys]) { var completer = new ChromeCompleter<int>.oneArg(); jsProxy.callMethod('getBytesInUse', [jsify(keys), completer.callback]); return completer.future; }
Future remove(keys) #
Removes one or more items from storage.
keys A single key or a list of keys for items to remove.
Future remove(dynamic keys) { var completer = new ChromeCompleter.noArgs(); jsProxy.callMethod('remove', [jsify(keys), completer.callback]); return completer.future; }
Future set(Map<String, dynamic> items) #
Sets multiple items.
items An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected.
Primitive values such as numbers will serialize as expected. Values with a
typeof
"object"
and "function"
will typically serialize to {}
, with
the exception of Array
(serializes as expected), Date
, and Regex
(serialize using their String
representation).
Future set(Map<String, dynamic> items) { var completer = new ChromeCompleter.noArgs(); jsProxy.callMethod('set', [jsify(items), completer.callback]); return completer.future; }
String toString() #
Returns a string representation of this object.
String toString() => jsProxy.toString();