0% found this document useful (0 votes)
17 views4 pages

Flutter - Introdução À Programação em Dart

Dart is an open-source, object-oriented programming language developed by Google, featuring C-style syntax and supporting concepts like classes and interfaces. It utilizes variables, data types, decision-making constructs, loops, and functions, while collections like lists and maps are used to manage data. Dart also supports object-oriented programming principles, allowing for the creation of classes and objects.
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)
17 views4 pages

Flutter - Introdução À Programação em Dart

Dart is an open-source, object-oriented programming language developed by Google, featuring C-style syntax and supporting concepts like classes and interfaces. It utilizes variables, data types, decision-making constructs, loops, and functions, while collections like lists and maps are used to manage data. Dart also supports object-oriented programming principles, allowing for the creation of classes and objects.
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/ 4

12/23/23 Flutter - Introduction to Dart Programming

Flutter - Introduction to Dart Programming

Dart is an open-source general-purpose programming language. It is originally


developed by Google. Dart is an object-oriented language with C-style syntax.
supports programming concepts like interfaces, classes, unlike other programming
Dart does not support arrays. Dart collections can be used to replicate data.
structures such as arrays, generics, and optional typing.

The following code shows a simple Dart program -

void main() {
Dart language is easy to learn
}

Variables and Data types


Variable is named storage location and Data types simply refers to the type and size of
data associated with variables and functions.

Dart uses the var keyword to declare variables. The syntax of var is defined below,

Dart

The final and const keyword are used to declare constants. They are defined as below −

void main() {
final a = 12;
const pi = 3.14;
print(a);
print(pi);
}

Dart language supports the following data types -

Numbers - It is used to represent numeric literals – Integer and Double.


Unable to access external links. 1/4
12/23/23 Flutter - Introduction to Dart Programming

Strings - It represents a sequence of characters. String values are specified in


either single or double quotes.
Booleans - Dart uses the bool keyword to represent Boolean values - true and false.
false.
Lists and Maps - It is used to represent a collection of objects. A simple List
can be defined as below −.

void main() {
var list = [1,2,3,4,5];
print(list);
}

The list shown above produces [1,2,3,4,5] list.

Map can be defined as shown here −

void main() {
var mapping = {'id': 1,'name':'Dart'};
print(mapping);
}

Dynamic - If the variable type is not defined, then its default type is dynamic.
The following example illustrates the dynamic type variable -

void main() {
dynamic name = "Dart";
print(name);
}

Decision Making and Loops


A decision making block evaluates a condition before the instructions are executed.
Dart supports If, If..else and switch statements.

Loops are used to repeat a block of code until a specific condition is met. Dart supports
for, for..in, while, and do..while loops.
Unable to access external links or websites. 2/4
12/23/23, 4:24 PM Flutter - Introduction to Dart Programming

Let us understand a simple example about the usage of control statements and loops -

void main() {
for( var i = 1 ; i <= 10; i++ ) {
if(i%2==0) {
print(i);
}
}
}

The above code prints the even numbers from 1 to 10.

Functions
A function is a group of statements that together perform a specific task. Let us look
into a simple function in Dart as shown here -

void main() {
add(3,4);
}
void add(int a,int b) {
int c;
c = a + b;
print(c);
}

The above function adds two values and produces 7 as the output.

Object Oriented Programming


Dart is an object-oriented language. It supports object-oriented programming features.
like classes, interfaces, etc.

A class is a blueprint for creating objects. A class definition includes the following −

Fields

Getters and setters

Constructors
The provided input is a URL and cannot be translated. Please provide text for translation. 3/4
12/23/23 Flutter - Introduction to Dart Programming

Functions

Now, let us create a simple class using the above definitions -

class Employee {
String name;

//getter method
emp_name
return name;
}
//setter method
void set emp_name(String name) {
this.name = name;
}
//function definition
void result() {
print(name);
}
}
void main() {
//object creation
Employee emp = new Employee();
employee1
emp.result(); //function call
}

Unable to access external content or links. 4/4

You might also like