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 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 the details of the bank account will be shown in a table. This is how our page will look like, at the start, upon opening the selection list:

Selecting a bank account number screen

Note

For the 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 the 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...