Using Lawndart to write offline web apps
What if the main requirement is that your app can work detached, providing universal offline key-value storage, whether IndexedDB is supported by your client's browsers or not? Then, Lawndart comes to the rescue.
Lawndart (https://github.com/sethladd/lawndart, but available via pub package) is not a new database, but rather a manager, which automatically chooses the best local storage mechanism available on the client. It was developed by Seth Ladd as a Dart rework of Lawnchair (http://brian.io/lawnchair/). You can see it in action in the project using_lawndart
.
How to do it...
Import the Lawndart package by adding lawndart:any
to your pubspec.yaml
file. The following is the relevant code from the startup script using_lawndart.dart
:
void main() { js = new JobStore(); // 1- creating and opening the database: js.open(); querySelector("#store").onClick.listen(storeData); } storeData(Event e) { var job = _jobData(); // 2- writing...