Dart is a client-optimized language for developing fast apps on any platform. This dart tutorial helps you learn Dart programming from scratch.
When you complete the entire tutorial, you’ll gain the following:
- Be confident with the Dart programming language.
- Understanding null-safety.
- Understanding object-oriented programming concepts.
- Master asynchronous programming.
- Be ready for Flutter.
Section 1. Getting Started
- Hello, World! – learn how to get started with Dart programming by developing the simple but famous program called
Hello, World!
. - Syntax – introduce to you the basic syntax of the Dart language.
Section 2. Variables & constants
Guide you on how to define variables, constants, and final variables in Dart.
Section 3. Basic Types
Let’s explore some of the core data types in Dart, including String
, int
, double
, and bool
, which allows you to work with text, whole numbers, decimal numbers, and boolean values, respectively.
Section 4. Control Flow
Learn how to make decisions in the program using various control flow statements.
- if – execute a block of code if a condition is true.
- if-else – execute a block of code if a condition is true. Otherwise, execute another block of code.
- if-else-if – check multiple conditions and execute a block of code if a condition is true.
- switch – select a branch for execution if an expression equals a value in a set of values.
- while – execute a block of code as long as a condition is true.
- do-while – execute at least one loop iteration and other iterations as long as a condition is true.
- for – execute a block of code a fixed number of times.
- break – skip the current iteration of a loop prematurely and start the next one immediately.
- continue – start the next iteration of the loop.
Section 5. Functions
Uncover how to of creating reusable code through the functions. This section will introduce you to a diverse range of function types, including anonymous functions and the concise elegance of arrow functions.
- Functions – show you how to define functions.
- Optional parameters – learn how to use optional parameters to make functions more flexible.
- Named parameters – use named parameters to make the parameters clear in the function calls.
- Functions are first-class citizens – learn how to assign a function to a variable, pass a function to another function, and return a function from another function.
- Anonymous functions – show you how to define anonymous functions which are the functions that do not have names.
- Arrow functions – show you how to define arrow functions.
Section 6. Classes
Learn how to define classes with constructors, fields, getters, and setters. After this section, you can create well-structured and encapsulated code that promotes code reuse and maintainability.
- Class – learn about objects and classes.
- this – explain what the
this
keyword means and how to use it effectively. - Constructor – show you how to use constructors to create and initialize objects.
- Private fields – discuss how to define private fields for a class by prefixing the field names with underscores (
_
). - Getter and Setter – show you how to use getters and setters to provide access to private fields and define computed properties.
- Constant constructor – learn how to use constant constructors.
- Static field and method – show you to use the static keyword to define a static field and method.
Section 7. Null safety
Learn how to make your program robust by using the null-safety feature in Dart.
- Null safety – understand how null safety works.
- Null-aware operators – learn various null-aware operators to handle null values.
Section 8. Advanced Classes
Master advanced class concepts in Dart, such as inheritance, abstract classes, and interfaces, to enhance code reusability and strengthen its robustness.
- Inheritance – use inheritance to enable a class to inherit from another class.
- super – use super to reference constructor of the parent class in the child class.
- Method Overriding – learn how to override methods from a parent class in a child class.
- Object identity & equality – show you how to compare two objects by identity and equality.
- Abstract Class – introduce to you the abstract classes.
- Interface – show you how to implement interfaces.
- Mixin – guide you on how to use mixins to reuse the code in classes from different hierarchies.
- Extension methods – learn how to use extension methods to extend existing libraries.
- Generics – learn how to define generic classes & methods.
- Enums – introduce to you the enumerated types or enums that represent a fixed number of constants.
- Factory constructors – show you how to use factory constructors effectively.
Section 9. Exceptions
Show you how to handle exceptions in Dart using the try-catch, and try-catch-finally statements. Also, guide you on how to raise an exception using the throw statement.
- try-catch – catch one or more exceptions using the try-catch statement.
- try-catch-finally – use the finally block to execute code whether an exception occurs or not.
- throw – show you how to use the throw statement to raise an exception.
Section 11. Iterables
Iterables represent a sequence of values that can be iterated. They provide a consistent interface for accessing elements.
Section 12. Asynchronous programming
Asynchronous programming enables efficient handling of time-consuming tasks without blocking execution. It provides constructs like async
and await
to initiate operations and continue with other tasks while awaiting results, resulting in responsive and non-blocking code.
- Event loop– learn how Dart uses an event loop to schedule asynchronous operations.
- Future – introduce to you the Future objects that represent the results of asynchronous operations.
- Stream – guide you on how to create a stream, and transform data from a stream.
- Generators – learn how to define synchronous and asynchronous generators to generate sequences of values.
Section 14. Dart 3 – New Features
- Dart Record – show you how to use the Record type to bundle multiple values into a single value.