Book Image

Learning Dart, Second Edition - Second Edition

By : Ivo Balbaert
Book Image

Learning Dart, Second Edition - Second Edition

By: Ivo Balbaert

Overview of this book

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

Spiral 3 – how to store data in a local storage


When a fully validated bank account object is created, we can store it in a local storage, also called the Web Storage API (see https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API), which is widely supported in modern browsers. In this mechanism, the application's data is 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 the storage and transportation 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...