A Flutter project for practice and example codes.
About Me
·
Report Bug
·
Request Feature
- Lab 3 - Dart Programming - Classes
- Lab 4 - Dart Programming - Classes Inheritance
- Lab 5 - Dart Programming - List
- Lab 6 - Dart Programming - Abstract Classes and Interfaces
- Lab 7 - Dart Programming - Exception Handling
- Lab 8 - Dart Programming – Functions
- Lab 9 - Dart Programming – Maps
- Lab 10 - Dart Programming – Sets
- Lab 11 - Dart Programming – Mixin
-
Instead of using maps, do the same thing using class or structure link
-
To improve the UI of Transaction App link
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter, view online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
In order to run your application from terminal, type:
$flutter emulators
Shows available emulators.
- To run an emulator, run 'flutter emulators --launch '.
- To create a new emulator, run 'flutter emulators --create [--name xyz]'.
$flutter emulators --launch iOS Simulator
$cd first_app
$flutter run
Dart is an object oriented programming language. It is primarily used for creating frontend user interfaces. And it is strongly typed.
Variables are used to temporarily store data.
var name = 'Hashir';
print(name); // Outputs ‘Hashir’
Here, var keyword is used to create variable. Equal(=) operator is used to assign value to the variable. And print() function is used to log the output.
Tip: It's common to use camelCase notation to name the variable.
In above example, variable name is of type String. Since Dart is able to infer the type though (because you initialise the variable with a value - 'Hashir'). It can also be written as follows.
String name = 'Hashir';
print(name); // Outputs 'Hashir'
Types describe the type of data of a variable. With types, you can ensure that a certain code expression only accepts numbers and the compiler “yells at you” if you pass wrong data.
Type | Example | More Information |
---|---|---|
String | String myName = 'Max'; | Holds text. You can use single or double quotes - just be consistent once you made your choice. |
num, int, double | int age = 30; double price = 9.99; | num refers to “number” - there are two types of numbers in Dart: Integers (numbers without a decimal place) and doubles (numbers with decimal places) |
object | Person = Person(); | Generally, everything in Dart is an object - even an integer. But objects can also be more complex, see below. |
Functions allow you to define code snippets which you can call whenever and as often as you want.
void sayHello(String name) {
print('Hello ' + name);
}
double addNumbers(double n1, double n2) {
return n1 + n2;
}
Dart is an object-oriented programming language - that means that every value in Dart is an object, even primitive values like text (= String) or numbers (= Integers and Doubles).
Objects are data structures and created with the help of “Classes” because every object needs a blueprint (=> the class) based on which you can then create (“instantiate”) it.
class Person {
var name = 'Max';
var age = 30;
void greet() {
print('Hi, I am ' + name + ' and I am ' + age.toString() + ' years old!';
}
}
The class only serves as a blueprint though! On its own, it does not give you an object! Instead, you can now create objects based on this class:
void main() {
var myself = Person();
print(myself.name); // use the . to access class properties & methods
}
- annonymus function jiska koi nam na ho,
- press 'Command' and hover the class object, to
- final vs const final is called a run time constant. when you code and made final, but you dont know the value to it, but know know what are you assigning to const eg:
- Pascel notation
- class is a widget
- we are creating a widget tree
- extend use to inherite
- this is a builder widget.
- flutter takes the control on screen pixcels
- every widget in flutter is actaully a dart class with a - build method.
- Scaffold is a design widget
Stateless widgets are immutable, meaning that their properties can’t change—all values are final. Two types of widgets:
- Stateless - which does not save the state
- Statefull - which maintains the state - like cookies, login sessions
there are two type of arguments like in python, positional aggumaents , named arguments Stateful widgets maintain state that might change during the lifetime of the widget. Implementing a stateful widget requires at least two classes: 1) a StatefulWidget class that creates an instance of 2) a State class. The StatefulWidget class is, itself, immutable, but the State class persists over the lifetime of the widget. flutter has control on each and every pixel of screen.
visible widget. => for handling input and output, eg. button invisible widget => for handling layout and control eg. column