delete method Null safety

  1. @override
Future<void> delete(
  1. Uri uri,
  2. [bool withDomainSharedCookie = false]
)
override

Delete cookies for specified uri. This API will delete all cookies for the uri.host, it will ignored the uri.path.

withDomainSharedCookie true will delete the domain-shared cookies.

Implementation

@override
Future<void> delete(Uri uri, [bool withDomainSharedCookie = false]) async {
  await _checkInitialized();
  await super.delete(uri, withDomainSharedCookie);
  final host = uri.host;
  if (_hostSet.remove(host)) {
    await storage.write(IndexKey, json.encode(_hostSet.toList()));
  }

  await storage.delete(host);

  if (withDomainSharedCookie) {
    await storage.write(DomainsKey, json.encode(domainCookies));
  }
}