Using Lawndart

IndexedDB doesn't (yet) work on all browsers. What if you don't know what browser your clients will use? Can we still provide universal offline key-value storage? The solution is Lawndart (https://github.com/sethladd/lawndart), a pub package that you can import in your app, which has been developed by Seth Ladd as a Dart reworking of Lawnchair. Lawndart presents an asynchronous, but consistent, interface to local storage, IndexedDb, and Web SQL. Your app simply works with an instance of the class Store and the factory constructor will try IndexedDB, Web SQL, and then, finally, local storage. This is implemented in Spiral s05_1; the only change with Spiral s05 is that IndexedDB (idb.dart) is replaced with Lawndart (lawndart.dart). For example, the load method is now written as:

Future load() {
    Stream dataStream = _store.all();
    return dataStream.forEach((taskMap) {      
      var task = new Task.fromDb(taskMap);
      tasks.add(task);
    });
}
Study lawndart.dart to see how the interface code changes.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.59