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

Chapter 5. Handling DOM in a New Way

A web application runs inside the browser that hosts the app; a single-page web app has become more and more common these days. This page may already contain some HTML elements or nodes, such as <div> and <input>, and your Dart code will manipulate and change them, but it can also create new elements. The user interface may even be entirely built up through the code. Besides this, Dart is responsible for implementing interactivity with the user (the handling of events, such as button clicks) and the dynamic behavior of the program, for example, fetching data from a server and showing it on the screen. In the previous chapters, we explored some simple examples of these techniques. Compared to JavaScript, Dart has simplified the way in which the code interacts with the collection of elements on a web page (called the DOM tree). This chapter teaches you this new method using a number of simple examples, culminating with a Ping Pong game. The...