0% found this document useful (0 votes)
90 views

Study Notes Flutter

The documents summarize programming concepts related to Dart and Flutter. Key points include: - Variables in Dart can hold different data types and their values can change. - Operators like remainder, equality, relational, logical and control structures like if/else, while and switch case are discussed. - Functions, parameters, return values, optional parameters and variable scope are covered. - Object oriented concepts like classes, constructors, getters/setters, inheritance and abstract classes are explained. - Collections like lists are introduced, with examples of creating lists of specific types. - Flutter widgets like SafeArea, TextStyle, Container, Column, Card and concepts like hot reload

Uploaded by

Anoop Thoombayil
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

Study Notes Flutter

The documents summarize programming concepts related to Dart and Flutter. Key points include: - Variables in Dart can hold different data types and their values can change. - Operators like remainder, equality, relational, logical and control structures like if/else, while and switch case are discussed. - Functions, parameters, return values, optional parameters and variable scope are covered. - Object oriented concepts like classes, constructors, getters/setters, inheritance and abstract classes are explained. - Collections like lists are introduced, with examples of creating lists of specific types. - Flutter widgets like SafeArea, TextStyle, Container, Column, Card and concepts like hot reload

Uploaded by

Anoop Thoombayil
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

25-03-2020

 Variable
If we use ‘var’ it is a dynamic variable. It can hold any type of values.ie we can change the
value that is being hold by this variable at any stage of the program.
Int, string, Bool, const, final,
 Concatenation &- before variables

26-03-2020

 Remainder operation % - output the remainder


 Equality and relational operators

==, !=>,<,>=,<=,

 Is, is!
 If
 Logical operator
! negating an expression
|| OR
&& AND
 While and do while loop
 Switch case and default
 Functions
 Return functions
>= to return an expression-simplifying the code
While printing remember- function is an expression, use ${}
o Void- doesn’t return anything
o String
o Int
 Return functions with parameters
String showname(string name)=>” Hello $name”
 String sayhello(String name, String lastname, int age)
 Optional parameters in functions [int age]
 Variables defined inside functions cannot be accessed outside the functions
27-03-2020

Object oriented programming

 Creating the classes- with various instance variables or otherwise called characteristics
 Assign the class to a variable – var mic = new Microphone
 There are two methods to create the actual object. Either with a constructor or without a
constructor.
Constructor- Microphone(this.name, this.color,this.model)
 Two or more constructors in the class definition so that mics with different characteristics
can be instantiated.
2nd Cosntructor- Microphone.initialize(this.name, this.color,this.model)
 Getters and Setter -to check again
 Inheritance of classes-

Class Person extends Anoop – Anoop inherits the characteristics of Person class

 Override of methods inherited from parent class- define the method in the class and print
what you want.
 Inheritance with constructor – in the child class press red button to create the constructor
for child class
After creating the class using red button-additional parameters can be added using
(this.elevation) command
 Abstract class
Basically is the mould class -like class Animal
Class person implements Animal class;

28-03-2020

Collections

Flutter App

 While using the scaffold widget- calling the app in home page is different. Need to call as a
new material app
Void main= >runApp(new MaterialApp(
Home: Scaffoldexample(),
));
 Inkwell app
 Icon button creation, adding gesture to a button,
 Inside coloumn widget, use children for widget creation not child.
30-03-2020

14-04-2020

Functions- Lecture 35 (File name rich)

- Functions can be void which means doesn’t return anything.


- Functions which returns any value can be string, int or Boolean. Functions can return only
one value. Other print functions can be written inside the function.
- If functions are returning only a single value we can use ‘ =>’ expression.
- Functions can be built in such a way that some values to be assigned while creating the
function.
ex: String Sayname(String name, String lastname) => “$name $lastname”;

inside main
Sayname(“Anoop”, “TS”);
- In functions like above any values can be made optional by putting a square bracket –
ex: String Sayname(String name, [String lastname]) => “$name $lastname”;

Lexical Scope of Functions -Lecture 37

- If a variable is defined inside a function that variable will not be accessible anywhere outside
that function.

Classes and Objects Lecture 40 (Filename classes)

- Classes are similar to the blueprint of a object.


- Classes will have properties (color, name etc) and methods(turn on, turn off etc).
- All functions (methods) should be declared within the class.

Creating a Constructor

- Press Cntrl+N and select the constructor.


- Similar to functions inside a constructor we can use [] for making the properties for an
object optional. Otherwise we have to pass all the values for the object inside the main.

Inheritance of Classes (filename inheritance classes)

- Keyword ‘extends’ can be used to inherit all the properties of a already existing class.
- To create a constructor for extended class – click on the yellow button. Within this
constructor we can add the instances of that particular class using ‘this.character’
expression.
- For Overriding methods of an inherited class – type the method in the extended class and
override.

Abstract class

- Abstract class is similar to a mold in which objects can be defined.


Abstract class Animal;
Class person implements Animal;
- Whenever an abstract class is implemented to a class- then all methods defined inside
abstract class to be defined.

List (File name listnew)

- A list can be created with only string values, integers etc

var onlystring = new List<String>(); // to create a list that can contain only string
values.

- Similarly, list can be created to contain only a class/objects.

ANGELA

Flutter Intro (File name Hello Flutter)

- The items which are written in small letters are the properties of a class for ex ‘appbar:’ of a
Scaffold class. For each class there will be a bunch of properties.

-www.draw.in – for drawing flowchart

- We can download demo flutter files from github.com

Hot Reload and Restart

- Hot reload works only if the code is written inside the stateless widget.
- Hot reload only loads the changes that have been made in the code. It doesn’t compile the
whole code from the beginning and that is why it is so fast. Also hot reload doesn’t change
the state of the project.(Count of donuts not changed)
- Hot restart similar to hot restart but will also change the state of the project.(Count of
donuts set to initial state of zero)

Container (Single child widget)

- Container expands to the whole available space if it doesn’t have any children.
- Safearea widget can be used to move the container away from notches.

General Widgets

Safe area –

- Safe area widget can be used to move the container away from notches.
- Left,right,top,bottom- true or false
- Minimum.Edgeinsets.all(value) can be put.
- //left: true,
//minimum: EdgeInsets.all(20),
-

Textstyle

- letterspacing,worspacing –
letterSpacing:2,wordSpacing: 5,

- decoration: TextDecoration.underline,
// decorationColor: Colors.deepPurpleAccent,
// decorationStyle: TextDecorationStyle.solid,
// decorationThickness: 5

-Margin

- Margin is for the outside of a container

Padding

-Padding is for the inside spacing of container.

-Edgeinsets

- Can be used along with both Padding and Margin.

- Edgeinsets.all, Edgeinsets.only, Edgeinsets.LTRB

Coloumn

- To create a container of width infinity -give width as double.infinity.

Mainaxis size

- Min/max
- Can be set to min or max- accordingly the size of coloumn will be limited to children of
coloumn.
-
Vertical Direction – Up or Down -Children can be laid from top to bottom or vice versa.

Main axis alignment –


- Start / end / center / space evenly /space between
- Accordingly the children will be glued to top or bottom or center.But mind that this is
different from Vertical direction Up or Down.

Cross axis alignment

- For alignment across the 90 degree axis ie horizontal direction in the case of coloumn.
- End /Start/ Strecth
- Stretch – will stretch the children across the horizontal direction.
Sized Box
- For creating spacing between children

Circle Avatar

- To create a circular image icon.


- CircleAvatar(
radius: 50,
backgroundImage: AssetImage('images/smile.jpg'),
),

Card Class

- Can be used instead of using a container for card.


- Padding cannot be provided for card class unlike container class.
- Card(
color: Colors.white,
margin: EdgeInsets.symmetric(vertical: 10,horizontal: 40),
//padding: EdgeInsets.symmetric(vertical: 10,horizontal: 20),
child:ListTile(
leading: Icon(
Icons.smartphone,
color: Colors.black,
size: 20,),
title: Text("+91 8129270904",
style: TextStyle(fontSize: 15,fontFamily: 'SourceSansPro',),
),
)
),

Divider Class

- To create a line.

- SizedBox(
width: 250,
height: 20,
child: Divider(
color: Colors.white,
thickness: 1.5,
),
),
-

Expanded Class

-The size of the child will adjust as per the screen size.

-flex can be used to determine how much space to be occupied compared to other widgets.
Image

- Code can be simplified as 1st one instead of 2nd one.


- child: Image.asset('images/dice1.png')
- child: Image(image: AssetImage('images/dice2.png'),

Animated Container (filename-animatedcontainer)

With below code animation will be done forth and back. Instead we can just set the values in the set
state- in that case animations will not be done back and forth.
FlatButton(
child: Text("Animate"),
onPressed: (){ setState(() {
height=height==100?200:100;
width =width==100?200:100;
color=color== Colors.tealAccent?Colors.red:Colors.tealAccent;
});

Animated Cross Fade


nimatedCrossFade(

duration: Duration(seconds: 1),


crossFadeState: FirstCrossFade?
CrossFadeState.showFirst:CrossFadeState.showSecond,
firstChild: Container(
height: 200,
width: 200,
child: Image.asset('images/android.png'),
),
secondChild: Container(
height: 200,
width: 200,
child: Image.asset('images/apple.png'),
),

),
OutlineButton(
child: Text("Animate CrossFade"),
onPressed: (){setState(() {
FirstCrossFade =!FirstCrossFade;

});

},
),

Animated Opacity
AnimatedOpacity(
opacity: opacity,
duration: Duration(seconds: 2),
child:Container(
height: 200,
width: 200,
child:Image.asset("images/apple.png"),
)

),
OutlineButton(
child: Text("Animate Opacity"),
onPressed: (){setState(() {
opacity =opacity==0?1:0;

});

You might also like