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 6 – working with a list of bank accounts


In this spiral, we will read all our Bank Account data from the local storage and display the numbers in a dropdown list. Upon selection, all details of the bank account are shown in a table. This is how our page looks, at the start, upon opening the selection list:

Selecting a bank account number screen

Note

For code files of this section, refer to chapter 6\bank_terminal_s6 in the code bundle.

In this spiral, we will let the code construct the web page:

void main() {
  readLocalStorage();                    (1)
  constructPage();                       (2)
  sel.onChange.listen(showAccount);      (3)
}

In line (1), the account numbers are read from local storage, extracted, and put into a list:

readLocalStorage() {
  account_nos = [];
  for (var key in window.localStorage.keys) {
    account_nos.add(key.substring(12)); // extract account number
  }
}

The method in line (2) calls two other methods, constructSelect (line (4)) and constructTable (line...