0% found this document useful (0 votes)
64 views21 pages

Dart

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views21 pages

Dart

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

DART

A R I H A R A S U D H A N
THIS BOOK
This book is written (typed) by
Ari, who hails from the South
and has keen interests in
Computer Science, Biology,
and Tamil Literature.
Occasionally, he updates his
website, where you can reach
out to him.
https://arihara-sudhan.github.io
WHAT IS DART?
Dart is a programming
language from Google. It is
optimized for building fast
apps on multiple platforms,
including web, mobile, and
desktop. Dart is the
foundation for Flutter, a
popular framework for
developing cross-platform
mobile applications. It is an
object-oriented, class-based
language with C-style syntax.
It is designed for client-side
development, enabling fast,
efficient, and scalable apps.
We can use it for web
development, mobile apps
(with Flutter), desktop apps,
command-line tools, and even
for server-side development.
Dart compiles to native
machine code, which
improves performance,
particularly on mobile devices.
For fast development cycles,
Dart supports hot reload,
allowing us to instantly view
changes. Dart comes with
libraries for collections, async
programming, file handling
and more. That’s all I know of
Dart. Snails have a dart. Dyk?
INSTALLING DART

If you don’t want to install it,


simply try dartpad, an online
Dart editor with support for
console and Flutter apps. It
looks pretty with different
colors in programming
statements.
HELLO, ARI!

Yep! As we have already seen,


it’s a C-style Syntax. The
output function is print(). Don’t
overlook the semicolon.
We can run the program by,
> dart run filename.dart
BASIX
Let’s have some explanations
on the SIX basics of Dart.
1. Basic Syntax
Dart is case-sensitive. Every
Dart program must have a
main() function, which acts as
the entry point as in C.
Statements end with a
semicolon (;), we don’t have
Automatic Semicolon Insertion
as in JavaScript.
2. Variables and Datatypes
Dart is statically typed, which
means that variables have
types, but it also supports type
inference, so we can skip type
declaration in many cases. We
can declare variables using
var, final, const, or explicit
types like int, double, etc.
var: Dart infers the type of the
variable based on the value
assigned to it.
final: A variable that can only
be set once. Once assigned,
its value can't be changed.

const: Like final, but the value


is compile-time constant. It is
usually used for values known
at compile time.
Dart has several built-in data
types.
Numbers: int (whole numbers),
double (floating).

String: Sequence of
characters enclosed in single
or double quotes.
Boolean: Represents true or
false values (bool type).

List: An ordered collection of


objects, similar to arrays in
other languages.

Set: An unordered collection


of unique objects.
Map: A collection of key-value
pairs.

Null: Dart has null safety built


in, which means variables
cannot contain null unless
explicitly declared nullable
(using ?).

ORDERED: Position of each element is fixed


UNORDERED: Position of each element is not fixed
3. Operators
Operator is a symbol to
perform a specific operation.
Arithmetic

Relational
Logical

Type Test (is)

Assignment
4. String Interpolation
We can embed expressions
inside string literals using $
{expression} or just
$variableName if it's a single
variable.

5. Null Safety
Dart ensures null safety, which
means non-nullable variables
cannot hold null values.
6. Collections
Dart has built-in support for
list, set, and map collections.

We’ll discuss them later in


detail.
CONTROL FLOW
Simply, everything is as in C.
That’s all I wanted to say!
If – Else If - Else

Ternary
Switch Case

For Loop
For-in Loop

While Loop
Do While Loop

Loop Control: Break, Continue


CONTROL FLOW
Simply, everything is as in C.

You might also like