Book Image

Learning Dart

Book Image

Learning Dart

Overview of this book

Table of Contents (19 chapters)
Learning Dart
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Spiral 3 – how to store data in local storage


When a fully validated bank account object is created, we can store it in local storage, also called the Web Storage API, that is widely supported in modern browsers. In this mechanism, the application's data are persisted locally (on the client-side) as a Map-like structure: a dictionary of key/value pairs. This is yet another example of the universal use of JSON for storage and transport of data (see Chapter 4, Modeling Web Applications with Model Concepts and Dartlero). Unlike cookies, local storage does not expire, but every application can only access its own data, up to a certain limit depending on the browser. With it, our application can also have an offline mode of functioning, when the server is not available to store the data in a database. Web Storage also has another way of storing data called sessionStorage, but this limits the persistence of the data to only the current browser session. So data is lost when the browser is closed...