key method

String? key({
  1. CStorageMethod method = CStorageMethod.local,
  2. required int index,
})

Gets the key from the index from the identified CStorageMethod.

Implementation

String? key({
  CStorageMethod method = CStorageMethod.local,
  required int index,
}) {
  if (method == CStorageMethod.local) {
    return web.window.localStorage.key(index);
  } else if (method == CStorageMethod.session) {
    return web.window.sessionStorage.key(index);
  } else {
    var ca = web.document.cookie.split(';');
    if (ca.length >= index) {
      return null;
    }
    var key = ca[index].split("=");
    return key[0];
  }
}