Dart in Action

Dart in Action

Chris Buckett

Language: English

Pages: 424

ISBN: 1617290866

Format: PDF / Kindle (mobi) / ePub


Summary

Dart in Action introduces Google's Dart language and provides techniques and examples showing how to use it as a viable replacement for Java and JavaScript in browser-based desktop and mobile applications. It begins with a rapid overview of Dart language and tools, including features like interacting with the browser, optional typing, classes, libraries, and concurrency with isolates. After you master the core concepts, you'll move on to running Dart on the server and creating single page HTML5 web applications.

About the Technology

Dart is a web programming language developed by Google. It has modern OO features, just like Java or C#, while keeping JavaScript's dynamic and functional characteristics. Dart applications are "transpiled" to JavaScript, and they run natively in Dart-enabled browsers. With production-quality libraries and tools, Dart operates on both the client and the server for a consistent development process.

About this Book

Dart in Action introduces the Dart language and teaches you to use it in browser-based, desktop, and mobile applications. Not just a language tutorial, this book gets quickly into the nitty-gritty of using Dart. Most questions that pop up while you're reading are answered on the spot! OO newbies will appreciate the gentle pace in the early chapters. Later chapters take a test-first approach and encourage you to try Dart hands-on.

To benefit from this book you'll need experience with HTML and JavaScript?a Java or C# background is helpful but not required.

Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.

What's Inside

  • Dart from the ground up
  • Numerous code samples and diagrams
  • Creating single-page web apps
  • Transitioning from Java, C#, or JavaScript
  • Running Dart in the browser and on the server

About the Author

Chris Buckett builds enterprise-scale web applications. He runs Dartwatch.com and is an active contributor to the dartlang list.

"Includes numerous examples of core language features as well as more advanced HTML5 features."-;From the Foreword by Seth Ladd, Developer Advocate, Google

Table of Contents

PART 1 INTRODUCING DART
  1. Hello Dart
  2. "Hello World" with Dart tools
  3. Building and testing your own Dart app
  4. PART 2 CORE DART
  5. Functional first-class functions and closures
  6. Understanding libraries and privacy
  7. Constructing classes and interfaces
  8. Extending classes and interfaces
  9. Collections of richer classes
  10. Asynchronous programming with callbacks and futures
  11. PART 3 CLIENT-SIDE DART APPS
  12. Building a Dart web app
  13. Navigating offline data
  14. Communicating with other systems and languages
  15. PART 4 SERVER-SIDE DART
  16. Server interaction with files and HTTP
  17. Sending, syncing, and storing data
  18. Concurrency with isolates

Android Apps for Absolute Beginners (2nd Edition)

Sams Teach Yourself the Twitter API in 24 Hours

Pro Android Python with SL4A

Regular Expressions Cookbook (2nd Edition)

Pro Website Development and Operations: Streamlining DevOps for large-scale websites

.net [UK] (July 2015)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

this practice is that when you’re designing a library, it’s good practice to provide interfaces in type definitions to allow the most flexibility to users of your library. Often, though, you intend the users of your library to use a specific class in most circumstances. The AuthService abstract class, which defines the interface, is a good example. Most of the time, users use the AuthService interface type in conjunction with the EnterpriseAuthService class that’s part of the same external

list of anything “is-a” List, but how does Dart achieve this when no type is specified? Behind the scenes, using an untyped generic is the same as using the dynamic type. The dynamic type, which we discussed in chapter 7, represents the untyped version of every class, and every instance of a class “is-a” dynamic. Thus, all lists of any type or no type are also always lists of dynamic: One final question arises, specifically with literal lists, because they have a specific syntax that Dart

serialized string to send the Role data over the web (which we’ll explore in part 3, later in the book). Remember Use the operator keyword in conjunction with the operator symbol to provide a new method in your class to overload the operator. Ensure that you overload operators only where doing so will aid readability of the code. You can overload indexer operators to allow map-like access to properties of your class. The dart:json library can convert classes that implement the Map

handler functions of the same element. You can add a second handler to the button: button.on.click.add( (event) => print("second event handler")); Although the event-handler function on the actions

won’t be called, both event handlers on the button will be called. Fortunately, there’s a way to stop this, too: calling the event’s stopImmediatePropagation() method, which stops the event from calling any further event handlers on any element. Modifying the Capture Phase You might at

for you. The postMessage(data, targetOrigin) function provided by the browser takes two parameters: the data, which you’re sending as JSON, and targetOrigin, which is the URL from which the receiving page was served. This means if you’re sending data to http://localhost:8080/DartExpense.html, the target origin is also http://localhost:8080/DartExpense.html. In most cases, you can use the value of window.location.href, because you’re sending messages in the same page, but being able to change

Download sample

Download