Вопрос

As mention in this SO, this is the way t get all objects stored in a localstorage:

for (var key in localStorage){
   console.log(key)
}

How would I do the same in Dart?

Это было полезно?

Решение

You can get the keys and values from Dart's local storage in almost the same way

Element log = document.query('#log');
log.nodes.clear();
for(int i=0; i<window.localStorage.length; i++) {
    var elm = new Element.tag("p");
    var key = window.localStorage.key(i);
    elm.innerHTML = "key ${key} value ${window.localStorage.getItem(key)}"; 
    log.nodes.add(elm);
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top