Mastering Dart
eBook - ePub

Mastering Dart

  1. 346 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Mastering Dart

About this book

Starting with a discussion about the basic features of Dart, we will dive into the more complicated concepts such as generics, annotation with reflection, errors and exceptions, which will help us improve our code. Moving on, you will learn how and when to create objects and also advanced techniques that will help you execute asynchronous code. You will also learn about the collection framework and how to communicate with the different programs written in JavaScript using Dart.

This book will show you how to add internalization support to your web applications and how i18n and l10n access can be embedded into your code to design applications that can be localized easily. You will be shown how to organize client-to-server communication and how different HTML5 features can be used in Dart. Finally, this book will show you how you can store data locally, break the storage limit, and prevent security issues in your web application.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Mastering Dart by Sergey Akopkokhyants in PDF and/or ePUB format, as well as other popular books in Computer Science & Web Development. We have over one million books available in our catalogue for you to explore.

Information

Mastering Dart


Table of Contents

Mastering Dart
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Beyond Dart's Basics
Modularity and a namespace
Modularity in software development
Modularity in Dart
Libraries
Functions and closures in different scopes
Naming functions with a variable
Passing a function as an argument to another function
Returning a function as a result of another function
Storing a function in data structures
Closures
Classes and mixins
Types
Classes
Inheritance
Interface
Mixins
Well-designed classes
To be private or not
Variables versus the accessor methods
Inheritance versus composition
Methods and operators
Checking the values of the parameters before using them
Well-designed methods
Summary
2. Advanced Techniques and Reflection
Generics
Raw types
Using generics
Generic types
Generic functions
Errors versus exceptions
Errors
Exceptions
Annotations
Built-in annotations
Deprecated
Override
Proxy
Custom annotations
Reflection
Introspection in action
Reflection in action
Summary
3. Object Creation
Creating an object
A generative constructor
A constructor with optional parameters
A named constructor
A redirecting constructor
A private constructor
A factory constructor
The factory method design pattern
The singleton design pattern
A constant constructor
Initializing variables
Syntactic sugar
Method call
Cascade method invocation
Summary
4. Asynchronous Programming
Call-stack architectures versus event-driven architectures
Call-stack architectures
Event-driven architectures
The Dart VM execution model
Synchronous versus Asynchronous code
Future
Future and Timer
Future and Microtask
Sync the Future class
Future with a value
Future with an error
Delaying the Future class
Zones
Simple zone example
Zone nesting
Zone values
Zone specifications
Interaction between zones
Tracking the zone execution
Isolates
Summary
5. The Stream Framework
Why you should use streams
Single-subscription streams versus broadcast streams
A single-subscription stream
A broadcast stream
An overview of the stream framework API
The Stream class
The validation methods of the Stream class
The search methods of the Stream class
The subset methods of the Stream class
Creating a stream
A new stream from the Future class
A new stream from the Iterable class
A new stream with periodically generated events
A new stream from the transformation pipe
A new stream from StreamController
What does the StreamSubscription class do?
Minimizing access to the Stream class members using StreamView
The Sink and EventSink interfaces
Importance of the StreamConsumer interface
What does the StreamSink class do?
Transforming streams with the StreamTransformer class
Traverse streams with StreamIterator
Summary
6. The Collection Framework
A Dart collection framework
Ordering of elements
The Comparable interface
The Comparator type
Collections and generics
The collection class hierarchy
The Iterable interface
Properties of the Iterable collection
Checking the items of a collection on a condition
The iterate over collection
The search over collection
Creating a new collection
Reducing a collection
Converting a collection
Generating a collection
The Lazy Iterable
The Iterable interface
BidirectionalIterator
The collection classes
List
LinkedList
Set
HashSet
LinkedHashSet
SplayTreeSet
Queue
Map
HashMap
LinkedHashMap
SplayTreeMap
Unmodifiable collections
The unmodifiable list
The unmodifiable map
Choosing the right collection
Summary
7. Dart and JavaScript Interoperation
Interoperation at a glance
The dart:js library
JsObject
JsFunction
JsArray
Type conversion
Direct type conversion
Proxy type conversion
Collection conversion
JsObject and instantiation
JsFunction and the this keyword
Dart with jQuery
How to create a shortcut to jQuery
Why does JProxy need a method call?
How does JProxy invoke jQuery?
An example project
How to get the jQuery version
How to perform actions in jQuery
How to use effects in jQuery
What is the impact on performance?
Summary
8. Internalization and Localization
The key principles
Executable code versus User Interface
Numbers and dates
Messages
Measuring units and currencies
Text input and layout
Formatting date and time
The Intl library
Changing a locale
Formatting numbers
Formatting dates
Internalizing messages
Adding parentheses
Adding gender
Adding select
Creating complex message translations
Bidirectional formatting
Internationalizing your web application
Extracting messages
Using Google Translator Toolkit
Using translated messages
Summary
9. Client-to-server Communication
Communication at a glance
The Internet protocol stack
Hypertext Transfer Protocol
Web server
Standalone HTTP communication via the dart:io library
Standalone HTTP communication via the http package
Web browser HTTP communication via the dart:html library
Web browser HTTP communication via the http package
AJAX polling request
AJAX long polling request
Server-Sent Events
WebSocket
Summary
10. Advanced Storage
Cookies
Web Storage
The Session storage
The Local storage
Web SQL
IndexedDB
Summary
11. Supporting Other HTML5 Features
The notification APIs
When to notify
Preventing repeated notifications
The native drag-and-drop APIs
Draggable content
The drag-and-drop events
Dragging data
Dragging the feedback image
Dragging effects
The drop target
Finishing a drop
Finishing a drag
The geolocation APIs
Determining the current location
Geolocation on maps
Tracking the present location
Canvas
Example – the canvas editor
Beginning with HTML
Moving to the main function
The CanvasWi...

Table of contents

  1. Mastering Dart