Book Image

DART Cookbook

By : Ivo Balbaert
Book Image

DART Cookbook

By: Ivo Balbaert

Overview of this book

Table of Contents (18 chapters)
Dart Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Data binding with polymer.dart


In the first recipe, we will go through an example that shows the complete mechanics of working with a Polymer component and data binding, and at the same time emphasizes some important best practices to work with polymer.dart. You can find the code in the project bank_terminal. The app creates an object of class BankAccount (which can be found in the lib folder) and populates it with the data that is shown. You can also provide a transaction amount and the balance of the account is updated. This is depicted in the following screenshot:

How to do it...

Perform the following steps to bind data with polymer.dart:

  1. First, install the polymer dependency in your project by adding polymer: ">=0.11.0 <0.12.0" to the pubspec.yaml file. Save the file in the editor and run pub get from the command line. This has to be accompanied by an import line; in web\bank_app.dart, we use import'package:polymer/polymer.dart'; but also in web\bank_app.html with a <link rel=...