TOPIC - 1 Dart & Flutter Basic
TOPIC - 1 Dart & Flutter Basic
⮚ Not only create Mobile App for IOS and Android but
also use for creating desktop and web including
embedded devices
Flutter Framework
SDK (Widget Library +dart)
⮚ Every Flutter app calls on both the Dart and Flutter APIs.
CoreConcept of Flutter
Everything is widget so that putting widget inside one another is
key concept in building Flutter app but some are not visible
How To Develop Flutter
<Dart Code>
-One Coding Technique for different platform
• Flutter SDK
https://flutter.dev/docs/development/tools/sdk/releases
What is Dart ?
2. Double
⮚ Strings
⮚ Boolean
⮚ Lists,Sets
⮚ Map
⮚ Runes and Symbol
⮚ Dynamic
Using Variable
Variable is like a box or container for storing value
temporary for later use .
Symbol
Variabletype name=value;
Example
String name=“Mg MG”;
int i=10;
double d=10.0;
bool b=true;
If----else
For doing comparison such as > ,<,==,!= you have to use if
..else
Symbol
if(condtion){
//write code here
}
else if(condition){
//write code here
}
else{
//write code here
}
If----else
Example
int mark=40;
if(mark>40 && mark<65){
print(“pass”);
}
else if(mark>79 && mark<=100){
print(“Credit”);
}
else{
print(“fail”);
}
Loop
For handling repetitive case ,you can use loop to avoid duplicate and
reduce code
Symbol
for(start ;condition;increment(or)decrement){
//write code here
}
while(condition){
//write code here
}
do{
//write code here
}while(condition)
Loop
Example
//constructing for loop
for(var i=0;i<3;i++){
print(“Hello ${i});
}
//constructing while
var w=0;
while(w<10){
print(“Hello ${w+1}“);
w++;
}
//constructing do while
var d=0;
do{
print(“Hello index:“+(d+1).toString());
d++;
}while(d<10)
List
List is similar to Array and ArrayList of other programming
and you can store multiple object
var listname=[value1,value2,value3];
(or)
listname.add(value);
(or)
List<type> numberdata=[];
Map
Map store data as key/value pair and its size can shrink and
grow at run time .
Using map
var mapname={‘key’:’value’};
(or)
mapname[‘key’]=value;
Function with Parameter
//function calling
showMyInfo(“Mg Mg”,18);
//function calling
showMyInfo(city:”Yangon”);
Lambada Function(Arrow Function)
Known as arrow function use for single expression
which use for single line of code .
Symbox
• Functioname()=> expression
• Return functioname()=>expression
Example
int calculateArea(int w,int h)=>w*h;
}
Class and Object
Example
class Book
{
void acceptBookInfo(){
print(“It is accepting Book Info”);
}
void printBookInfo(){
print(“It is printing book info”);
}
}
Class and Object
Object is implementation of that templte
Syntax
Classname name=new Classname();
Example
Book he=new Book();
he.acceptBookInfo();
He.printBookInfo();
Class and Constructor
✓ Constructor is entry point or initialization point of class.
✓ To construct constructor you have to use same name as class without
adding void or return type.
✓ You can construct multiple constructor and like function there are
named and positional constructor and also exist default constructor(no
args constructor)
Syntax
Class classname{
public classname(){
//initializing class as object
}
}
Class and Constructor
Example 1
class Book{
public Book(){
print(“Book Info”);
}
}
Example 2
class Book{
String title;
int year;
public Book({this.title;,this.year});
}
Final & Const
Both final and Const can be used in declaring constants.
⮚ Final known as run-time constant
Syntax
final int test;
test=10;
Example
Class Config{
static String url=www.abc.com;
}
//calling without object
Config.url=“something”;
print(Config.url);