문제

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