1

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?

Community
  • 1
  • 1
Andreas Köberle
  • 98,250
  • 56
  • 262
  • 287

1 Answers1

2

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);
}
Günter Zöchbauer
  • 558,509
  • 191
  • 1,911
  • 1,506
Lars Tackmann
  • 19,235
  • 13
  • 63
  • 83