Professional Documents
Culture Documents
REVIEWER
REVIEWER
What is Flutter
• released the first version for developers in 2018. Dynamic type variable in Dart:
• an SDK for building fast-moving and engaging cross-platform mobile apps provided by Google. • This is a special variable initialized with keyword dynamic. The variable declared with this data type
• Flutter supports compiling code on both Android and iOS using a single code base written in Dart can store implicitly any value during running the program. It is quite similar to var datatype in Dart,
• Dart is a development language for Flutter apps. but the difference between them is the moment you assign the data to variable with var keyword it
• In 2020, it received enhanced functionality and now can be used to create Flutter web apps and is replaced with the appropriate data type.
Flutter desktop apps (for macOS). Syntax:
• Flutter is a unique cross-platform tool type and does not need intermediate components to connect dynamic variable_name;
to device features such as a camera or Bluetooth.
• This leads to better performance and helps create a great UX. Operators in Dart
• it uses its own user interface components instead of platform-specific ones like UIView in iOS or • The operators are special symbols that are used to carry out certain operations on the operands.
Fragments and ViewGroups in Android. • The Dart has numerous built-in operators which can be used to carry out different functions, for
example, ‘+’ is used to add two operands.
What is DART • Operators are meant to carry operations on one or two operands.
• Dart is an open-source general-purpose programming language developed by Google. It supports
application development in both client and server-side. But it is widely used for the development of Different types of operators in Dart
android apps, iOS apps, IoT(Internet of Things), and web applications using the Flutter Framework. • Arithmetic Operators
• Dart is a dynamic, class-based, object-oriented programming language with closure and lexical • Relational Operators
scope. Syntactically, it is quite similar to Java, C, and JavaScript. • Type Test Operators
• Bitwise Operators
TWO TYPES OF COMPILATION TECHNIQUES. • Assignment Operators
• AOT (Ahead of Time) - It converts the Dart code in the optimized JavaScript code with the help of • Logical Operators
the dar2js compiler and runs on all modern web-browser. It compiles the code at build time. • Conditional Operator
• JIT (Just-In-Time) - It converts the byte code in the machine code (native code), but only code that • Cascade Notation Operator
is necessary.
History Arithmetic Operators
• Dart was revealed for the first time in the GOTO conference in the month of 10th - 12th October
2011 at Aarhus, Denmark. This class of operators
• It is initially designed by the Lars bark and Kespar and developed by Google.
Why Dart? contain those operators
• Dart is a platform-independent language and supports all operating systems such as Windows,
Mac, Linux, etc. which are used to perform
• It is an open-source language, which means it available free for everyone. It comes with a BSD
license and recognized by the ECMA standard. arithmetic operation on the
• It is an object-oriented programming language and supports all features of oops such as
inheritance, interfaces, and optional type features. operands
• Dart is very useful in building real-time applications because of its stability.
• Dart comes with the dar2js compiler which transmits the Dart code into JavaScript code that runs
on all modern web browser.
• The stand-alone Dart VM permits Dart code to run in a command-line interface environment.
Dart – Comments
• In every programming language comments play an important role for a better understanding of the
code in the future or by any other programmer. Comments are a set of statements that are not
meant to be executed by the compiler. They provide proper documentation of the code.
Dart – Variables
• A variable name is the name assign to the memory location where the user stores the data and
that data can be fetched when required with the help of the variable by calling its variable name.
Variable Declaration:
• To declare a variable:
Syntax: Type Test Operators
type variable_name; • This class of operators contain those operators which are used to perform comparison on the
• To declare multiple variables of same type: operands.
Syntax:
type variable1_name, variable2_name, variable3_name, ....variableN_name;
Conditions to write variable name or identifiers :
• Variable name or identifiers can’t be the keyword.
• Variable name or identifiers can contain alphabets and numbers.
• Variable name or identifiers can’t contain spaces and special characters, except the underscore(_)
and the dollar($) sign.
• Variable name or identifiers can’t begin with number.
Note:
Dart supports type-checking, it means that it checks whether the data type and the data that
variable holds are specific to that data or not.
Keywords in Dart:
Logical Operators
• This class of operators contain those operators which are used to logically combine two or more
conditions of the operands
• The number in Dart Programming is the data type that is used to hold the numeric value. Dart
numbers can be classified as:
• The int data type is used to represent whole numbers.
• The double data type is used to represent 64-bit floating-point numbers.
• The num type is an inherited data type of the int and double types.
Example
void main() {
// declare an integer
int num1 = 2;
// declare a double value
double num2 = 1.5;
// print the values
print(num1);
print(num2);
var a1 = num.parse("1");
var b1 = num.parse("2.34");
Conditional Operators
var c1 = a1+b1;
print("Product = ${c1}");
}
String
• It used to represent a sequence of characters. It is a sequence of UTF-16 code units. The keyword
string is used to represent string literals. String values are embedded in either single or double-
quotes.
SAMPLE CODE:
void main() {
String string = ‘Dart Porgramming';
String str = 'Coding is ';
String str1 = 'Fun';
print (string);
print (str + str1);
}
Boolean
Cascade Notation Operators • It represents Boolean values true and false. The keyword bool is used to represent a Boolean
• This class of operators allows you to perform a sequence of operation on the same element. It literal in DART.
allows you to perform multiple methods on the same object. void main() {
String str = 'Coding is ';
String str1 = 'Fun';
if (count == 5) { L3
break; DART – FUNCTIONS
} Function
} while (count <= 10); Function is a set of statements that take inputs, do some specific computation and produces output.
print(“Class, you are out of do..while loop"); Functions are created when certain statements are repeatedly occurring in the program and a function is
} created to replace them.
Using break inside for loop Functions make it easy to divide the complex program into smaller sub-groups and increase the code
void main() reusability of the program.
{ Function Syntax:
for (int i = 1; i <= 10; ++i) { return_type function_name ( parameters ) {
if (i == 2) // Body of function
break; return value;
}
//To call a function
print(“Class, you are inside loop $i"); function_name (argument_list);
} • function_name defines the name of the function.
• return_type defines the datatype in which output is going to come.
• return value defines the value to be returned from the function.
print(“Class, you are out of loop"); Example: A dart program that calculates the sum of two numbers.
{
print("Welcome to $str1");
The recursive function is those functions in which function calls itself. It is a good way to avoid repeatedly calling the }
same function to get the output.’ }
Object
Example: Recursive function for fibonacci series.
int fibonacci(int n) • An object is an instance of a class.
{ • Objects are allocated memory space whenever they are created.
// This is recursive function as it calls itself • An object is created many times as per requirement.
return n < 2 ? n : (fibonacci(n - 1) + fibonacci(n - 2)); • Objects can be manipulated.
} • Each object has its own values, which are associated with it.
• Objects are like a variable of the class.
Syntax for Object
1 1 2 3 5 8 13 21
void main()
var object_name = new class_name([ arguments ]);
{
new is the keyword use to declare the instance of the class
var i = 8; // input
object_name is the name of the object and its naming is similar to the variable name in dart.
print('fibonacci($i) = ${fibonacci(i)}');
class_name is the name of the class whose instance variable is been created.
}
arguments are the input which are needed to be pass if we are willing to call a constructor.
dot(.) operator
Class
• Used to access the field
• Class is used as a template for declaring and creating the objects.
Syntax:
• When a class is created, no memory is allocated.
// For accessing the property
• The class has to be declared only once.
object_name.property_name;
• A class cannot be manipulated as they are not available in the memory.
// For accessing the method
• It is declared with the class keyword.
object_name.method_name();
• Class does not contain any values which can be associated with the field.
Example
• A class is a blueprint for creating objects (a particular data structure), providing initial values for state
class ite312 {
(member variables or attributes), and implementations of behavior (member functions or methods).
String str1 = "";
Syntax of Class
void itp() {
print("Welcome to $str1");
class class_name { }
// Body of class }
} void main() {
class is the keyword use to initialize the class. // Creating Instance of class
class_name is the name of the class. var itpClass = new ite312();
Body of class consists of fields, constructors, getter and setter methods, etc. itpClass.str1 = "ITE 312 Class for Today!!";
Example itpClass.itp();
class itp324 { }
// Creating Field inside the class Constructors
String str1; • Constructors are a special method that is used to initialize an object when created in the program.
// Creating Function inside class • In object-oriented programming when an object is created, it automatically calls the constructor.
void itp()
• All classes have their default constructor which is created by the compiler when class is called, • There is no need to create a class object to access a static variable or call a static method: simply
moreover one can also define constructor of its own. But, you must note that if you do so then the put the class name before the static variable or method name to use them.
default constructor will not be created and will be ignored. Dart Static Variables
Syntax of a Constructor
• The static variables belong to the class instead of a specific instance. A static variable is common
class_name( [ parameters ] ){ to all instances of a class: this means only a single copy of the static variable is shared among all
// Constructor Body the instances of a class. The memory allocation for static variables happens only once in the class
} area at the time of class loading.
class_name is the name of the class whose constructor is being created.
parameters are optional features and they can and can’t be defined for the constructor. The default constructor has
Declaring Static Variables
no parameter defined in it.
Constructor body is the body of the constructor and is executed when the constructor is called i.e when an object is
created. Syntax:
Constructors don’t have any return type. static [data_type] [variable_name];
Example 1: Creating a constructor in Dart Example:
static var emp_dept;
Full Example
class G{
class Employee {
// Creating Constructor
static var emp_dept; //declaring static variable
G() {
var emp_name;
print('Constructor is being created');
int emp_salary;
}
showDetails() {
String str1;
print("Name of the Employee is: ${emp_name}");
void itp(){
print("Salary of the Employee is: ${emp_salary}");
print("Welcome to $str1");
print("Dept. of the Employee is: ${emp_dept}");
}
}
}
}
Example:
void main() {
Class G{
Employee e1 = new Employee();
// Creating Constructor with parameter
Employee e2 = new Employee();
G(int a) {
Employee.emp_dept = "MIS"; //accessing static variable