length method

  1. @override
Future<int?> length()

Returns an integer representing the number of data items stored in the Storage object.

NOTE for Web: this method will have effect only if the iframe has the same origin.

Officially Supported Platforms/Implementations:

  • Android native WebView
  • iOS
  • MacOS
  • Web

Implementation

@override
Future<int?> length() async {
  var result = await controller?.evaluateJavascript(source: """
  window.$webStorageType.length;
  """);
  return result != null ? int.parse(json.decode(result)) : null;
}