Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Foreword

Preface

Acknowledgments

About this Book

About the Cover Illustration

Part 1. Introducing Dart

Chapter 1. Hello Dart

1.1. What is Dart?

1.1.1. A familiar syntax to help language adoption

1.1.2. Single-page application architecture

1.2. A look at the Dart language

1.2.1. String interpolation

1.2.2. Optional types in action

1.2.3. Traditional class-based structure

1.2.4. Implied interface definitions

1.2.5. Factory constructors to provide default implementations

1.2.6. Libraries and scope

1.2.7. Functions as first-class objects

1.2.8. Concurrency with isolates

1.3. Web programming with Dart

1.3.1. dart:html: a cleaner DOM library for the browser

1.3.2. Dart and HTML5

1.4. The Dart tool ecosystem

1.4.1. The Dart Editor

1.4.2. Dart virtual machine

1.4.3. Dartium

1.4.4. dart2js: the Dart-to-JavaScript converter

1.4.5. Pub for package management

1.5. Summary

Chapter 2. “Hello World” with Dart tools

2.1. The command-line Dart VM

2.2. “Hello World” with the Dart Editor

2.2.1. Exploring the Dart Editor tools

2.2.2. The relationship between Dart and HTML files

2.2.3. Running “Hello World” with Dartium

2.2.4. Using dart2js to convert to JavaScript

2.2.5. Generating documentation with dartdoc

2.2.6. Debugging Dart with breakpoints

2.3. Importing libraries to update the browser UI

2.3.1. Importing Dart libraries

2.3.2. Accessing DOM elements with dart:html

2.3.3. Dynamically adding new elements to the page

2.4. Summary

Chapter 3. Building and testing your own Dart app

3.1. Building a UI with dart:html

3.1.1. Entry-point HTML

3.1.2. Creating dart:html elements

3.1.3. Creating a new Element from HTML snippets

3.1.4. Creating elements by tag name

3.1.5. Adding elements to an HTML document

3.2. Building interactivity with browser events

3.2.1. Adding the PackList item from a button click

3.2.2. Event handling with Dart’s flexible function syntax

3.2.3. Responding to dart:html browser events

3.2.4. Refactoring the event listener for reuse

3.2.5. Querying HTML elements in dart:html

3.3. Wrapping structure and functionality with classes

3.3.1. Dart classes are familiar

3.3.2. Constructing the PackItem class

3.3.3. Wrapping functionality with property getters and setters

3.4. Unit-testing the code

3.4.1. Creating unit tests

3.4.2. Defining test expectations

3.4.3. Creating a custom matcher

3.5. Summary

Part 2. Core Dart

Chapter 4. Functional first-class functions and closures

4.1. Examining Dart functions

4.1.1. Function return types and the return keyword

4.1.2. Providing input with function parameters

4.2. Using first-class functions

4.2.1. Local function declarations

4.2.2. Defining strong function types

4.3. Closures

4.4. Summary

Chapter 5. Understanding libraries and privacy

5.1. Defining and importing libraries in your code

5.1.1. Defining a library with the library keyword

5.1.2. Importing libraries with import

5.2. Hiding functionality with library privacy

5.2.1. Using privacy in classes

5.2.2. Using private functions in libraries

5.3. Organizing library source code

5.3.1. Using the part and part of keywords

5.4. Packaging your libraries

5.5. Scripts are runnable libraries

5.6. Summary

Chapter 6. Constructing classes and interfaces

6.1. Defining a simple class

6.1.1. Coding against a class’s interface

6.1.2. Formalizing interfaces with explicit interface definitions

6.1.3. Using multiple interfaces

6.1.4. Declaring property getters and setters

6.2. Constructing classes and interfaces

6.2.1. Constructing class instances

6.2.2. Designing and using classes with multiple constructors

6.2.3. Using factory constructors to create instances of abstract classes

6.2.4. Reusing objects with factory constructors

6.2.5. Using static methods and properties with factory constructors

6.3. Creating constant classes with final, unchanging variables

6.3.1. Final values and properties

6.3.2. The constructor initialization block

6.3.3. Using the const keyword to create a const constructor

6.4. Summary

Chapter 7. Extending classes and interfaces

7.1. Extending classes with inheritance

7.1.1. Class inheritance

7.1.2. Inheriting constructors

7.1.3. Overriding methods and properties

7.1.4. Including abstract classes in a class hierarchy

7.2. Everything is an object

7.2.1. Testing the “is-an” relationship with Object

7.2.2. Using the “is-an” Object relationship

7.2.3. Using toString() functionality inherited from the base Object class

7.2.4. Intercepting noSuchMethod() calls

7.2.5. Other default functionality of the Object class

7.3. Introducing the dynamic type

7.3.1. Using the dynamic type annotation

7.4. Summary

Chapter 8. Collections of richer classes

8.1. Working with collections of data

8.1.1. Collections of objects

8.1.2. Using the concrete implementations of the Collection interface

8.1.3. Making collections specific with generics

8.1.4. Storing lists of key/value pairs with generic maps

8.2. Building your own generic classes

8.2.1. Defining a generic class

8.2.2. Using your custom generic class

8.2.3. Restricting the types that can be used as placeholders

8.3. Operator overloading

8.3.1. Overloading comparison operators

8.3.2. Surprising use for operator overloading

8.3.3. Overloading indexer operators

8.4. Summary

Chapter 9. Asynchronous programming with callbacks and futures

9.1. Why web apps should be asynchronous

9.1.1. Modifying your app to be asynchronous

9.2. Using callbacks with async programming

9.2.1. Adding async callbacks to Dart Lottery

9.2.2. Ensuring that all async callbacks are complete before continuing

9.2.3. Nesting callbacks to enforce async execution order

9.3. Introducing the Future and Completer pair

9.3.1. Passing around future values

9.3.2. Ordering async calls by chaining futures

9.3.3. Waiting for all futures to complete

9.3.4. Transforming nonfuture values into futures

9.4. Unit-testing async APIs

9.4.1. Testing async callback functions

9.4.2. Testing future values

9.5. Summary

Part 3. Client-side Dart apps

Chapter 10. Building a Dart web app

10.1. A single-page web app design

10.1.1. Introducing DartExpense

10.1.2. Dart application structure

10.1.3. Dart app execution flow

10.2. Building a UI with dart:html

10.2.1. Understanding the Element interface

10.2.2. Element constructors in action

10.2.3. Building interaction with views and elements

10.2.4. Building a simple generic grid

10.3. Handling browser events with dart:html

10.3.1. Managing browser event flow

10.3.2. Common event types

10.4. Summary

Chapter 11. Navigating offline data

11.1. Integrating navigation with the browser

11.1.1. Using pushState() to add items to the browser history

11.1.2. Listening for popState events

11.2. Using browser cookies to enhance user experience

11.2.1. Storing data in a cookie

11.2.2. Reading data from a cookie

11.3. Persisting data offline with Web Storage

11.3.1. Converting Dart objects to JSON strings

11.3.2. Converting JSON strings to Dart objects

11.3.3. Storing data in browser web storage

11.4. Summary

Chapter 12. Communicating with other systems and languages

12.1. Communicating with JavaScript

12.1.1. Sending data from Dart to JavaScript

12.1.2. Receiving data in JavaScript sent from Dart

12.1.3. Sending data from JavaScript to Dart

12.2. Communicating with external servers

12.2.1. Understanding the same-origin security restrictions

12.2.2. Using JSONP to request data from external servers

12.3. Building installable, server-less browser apps

12.3.1. Using AppCache to run applications offline

12.3.2. Packaging your app as a Chrome web app

12.4. Summary

Part 4. Server-side Dart

Chapter 13. Server interaction with files and HTTP

13.1. Running server-side Dart scripts

13.1.1. Accessing command-line arguments

13.1.2. Accessing files and folders with dart:io

13.2. Serving browser HTTP requests

13.2.1. Using the Dart HttpServer

13.2.2. Serving static files over HTTP

13.3. Serving clients with a RESTful API

13.3.1. Sending a directory list as JSON data

13.3.2. Sending the file content as JSON data

13.3.3. Adding the client-side user interface

13.4. Summary

Chapter 14. Sending, syncing, and storing data

14.1. Serving DartExpense from the server

14.2. Using web sockets for two-way communication

14.2.1. Connecting web sockets on the client side

14.2.2. Handling web socket connections on the server

14.2.3. Using web sockets for cross-browser synchronization

14.3. Storing data with HttpClient and CouchDB

14.3.1. A quick CouchDB primer

14.3.2. Sharing the Expense model class between client and server

14.3.3. Adding server support for data persistence

14.4. Summary

Chapter 15. Concurrency with isolates

15.1. Using isolates as units of work

15.1.1. Creating an isolate

15.1.2. One-way isolate communication

15.1.3. Two-way isolate communication

15.2. Loading code dynamically

15.2.1. Spawning an isolate from a filename

15.2.2. Defining a dynamic source file

15.3. Spawning multiple workers

15.4. Summary

Appendix A. Core language reference

A.1. Variable declaration

A.1.1. Declaring variables with the var keyword or type name

A.1.2. Declaring final (read-only) variables

A.1.3. Populating variables with literal syntax

A.1.4. Generic lists and maps

A.2. Functions

A.2.1. Longhand function syntax

A.2.2. Shorthand function syntax

A.2.3. Function parameters

A.2.4. First class functions

A.3. Flow control and iterating

A.3.1. Decision making for controlling flow

A.3.2. Loops and iterating

Appendix B. Defining classes and libraries

B.1. Classes and interfaces

B.1.1. Defining classes

B.1.2. Class inheritance

B.1.3. Abstract classes

B.1.4. Implicit interfaces

B.1.5. Static methods and properties

B.2. Libraries and privacy

B.2.1. Defining libraries

B.2.2. Library privacy

Index

List of Figures

List of Tables

List of Listings

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.200.14