delete method Null safety

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

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

withDomainSharedCookie true will delete the domain-shared cookies.


Future<void> delete(Uri uri, [bool withDomainSharedCookie = false]) async {
  await _checkInitialized();
  await super.delete(uri, withDomainSharedCookie);
  final 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));