, , , ,



https://leanpub.com/learndartthehardway Just published! Just get the feel:

1. Why Dart Language?

You can answer this question in one sentence. Dart is a great fit for both – Mobile Apps and Web Apps. Dart is free and open source and the repository is available at https://github.com/dart-lang. And at the same time you may get the feel of the language at the official website: https://www.dartlang.org/. In this introductory chapter, let us try to understand why learning Dart language is important for us to build a mission critical Mobile Apps on iOS and Android. It is important to note, in the very beginning, the developers around the world use Dart to create high-quality apps for iOS and Android and the web. It is feature rich so that client-side development is also possible. As we progress step-by-step, we will see how correct this statement is. In the first half of the book we will learn Dart language and the second half continues to another book “Beginning Flutter with Dart”, where we will learn Dart alongwith Flutter, a rich and powerful framework for building mobile apps. In that book we will build our first mobile apps from a single codebase on iOS and Android. If you want to learn building native iOS and Android mobile apps and web apps using Dart, then this book serves as a good introduction because it is designed to give you a complete idea about how Dart works. Let us have a quick look at the core features of Dart programming language first. First of all, it is extremely productive. If you already know any object oriented programming language such as C++, C# or Java, it will not take a few days for you to learn Dart language. If you are absolute beginner, then it is good that you are starting to learn your first programming language which has clear and concise syntax. You will also have a great support of rich and powerful core libraries and thousands of packages. As an absolute beginner, you don’t have to worry about the libraries now. We will learn together to use them later when time comes. Dart is fast and furious, and the performance is high across mobile devices and the web because it optimizes the compilation power. Besides, its portability rate is extremely good. It compiles to ARM and x86 code, so that Dart mobile apps can run on iOS and Android and beyond. Now here is a complementary note for the absolute beginners: there is a difference between ARM and X86 processors; the ARM processors follow a RISC (Reduced Instruction Set Computer) architecture, while x86 processors are CISC (Complex Instruction set Architecture); because of these features x86 processors are considered to be faster than ARM. At the same time for web apps, Dart has a very close Let us see our first Dart code.
//code 1.1 main() { print(“Hello World!”); } //output Hello World!
Let us write some more console based code to get the feel of Dart. At the same time we will know what are the most basic syntaxes and how they work together.
//code 1.2 main() { print(“Hello World!”); //calling a function doSomething(); } //define a function doSomething(){ print(“Do something!”) //calling a function inside another function lifeIsShort(); } //defining another function lifeIsShort(){ print(“Life is too short to do so many things.”); }
In the above code, we have defined two functions and nesting another function inside one function we have called them together through a single function. However, there is a mistake in our code. It is an intended mistake so that you understand how debugging takes place in Dart.
Watch the output: //output of code 1.2 bin/main.dart:12:24: Error: Expected ‘;’ after this. print(“Do something!”)
We have forgotten to place a semicolon after displaying an output. Let us correct it and run the program again. In Android Studio you may use “Shift+F10” to run the code.
//output of code 1.2 Hello World! Do something! Life is too short to do so many things.
Now it is OK. We have learned many things in our first code. The very first lesson teaches us the most basic thing of all knowledge. You learn from your mistake. You should always be careful about the syntaxes. Missing a semicolon, or a dollar sign before a variable could be a big game changer. Especially when you are going to build a large scale mobile application on iOS or Android. You have seen how we have commented on our code. Try to contribute as much comment as possible to clear your standpoint so that when another person reads your code, he/she will understand it, visualize it as you have visualized your code while writing. We will discuss more about comments at the right time. We have started our code with the top level function “main()”; it is required and special in nature because here the application executes. So inside the main() function we have called a function “doSomething()” which has a nested-function inside it “lifeIsShort()”. Each function gives a display output with “print()”; it is a handy way to display any output. We have covered many things in our first program. If you are a complete beginner, you are at a loss to understand the above remarks. You may feel puzzled about those words, such as, function, comment, displaying output etc. Because of that, the next few chapters are dedicated to the beginners. The experienced programmers may skip that pat.  


A Few Words About DART IDE

1. Why Dart Language?

2. Learning Dart from Scratch: Variables, Operators and Conditionals, Control Flow

Variables Store References

Built in Types in Dart

Suppose, You don’t like Variables

More about built-in types

Play with Number and Double

Understanding Strings

To be True or to be False

Introduction to Collections: Arrays are Lists in Dart

Get, Set and Go

Operators are Useful

Equality and relational operators

Type test operators

Assignment operators

Summery of the First Part

2.1. Control the flow of your code

If and Else

Conditional Expression

2.2 Looking at Looping

For Loops

While and Do-While

Patterns in Looping

For Loop Labels

Continue with For Loop

Decision making with Switch and case

3. Functions and Objects

A Short Introduction to Function

A Short Introduction to Objects

3.1. Digging Deep into Object Oriented Programming

Why we need Constructors

How to implement Classes

How Functions or Methods Work

Lexical Scope in Function

A few words about Getter and Setter

Different types of Parameters

More about Constructors

4. Inheritance and Mixins in Dart

Mixins: Adding more Features to a Class

5. Abstract Class and Methods

6. Advantage of Interfaces

7. Static Variables and Methods

8. Anonymous Functions: Lambda, Higher Order Functions, and Lexical Closures

Lambda: The Anonymous Function

Exploring Higher Order Functions

Closure is a Special Function

9. Data Structures and Collections

Lists: Fixed Length and Growable

Set: An Unordered Collections of Unique Items

Maps: the Key, Value Pair

Queue is Open-Ended

10. Callable Classes

11. Exception Handling

12. Dart Packages and Libraries

13. What Next