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
  • 106,652
  • 57
  • 273
  • 297

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
  • 623,577
  • 216
  • 2,003
  • 1,567
Lars Tackmann
  • 20,275
  • 13
  • 66
  • 83