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

Initializing the Travel Impressions model with data


After the model is designed (refer to the spiral 4 of the Travel Impression Model figure) and its code is generated, the model will be initialized with some basic data starting with its entries. This is done in the lib/travel/impressions/init.dart file:

initTravelImpressions(var entries) {
  _initCountries(entries);
  _initTravelers(entries);
}

We will start by creating a country and some of its places, together with the web links, from the entries parameter:

_initCountries(var entries) {
  var countries = entries.countries;
  var country = new Country(countries.concept);
  country.code = 'BA';
  country.name = 'Bosnia and Herzegovina';
  countries.add(country);

In the Country concept of the graphical model, there is no code attribute of the String type. The code attribute is inherited from dartling. In a concept, you do not need to use the inherited code attribute. However, if you use it, its values must be unique. Note that a new country...