Pregunta

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?

¿Fue útil?

Solución

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);
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top