Function

 void main() {


// print(myClass(),); //Instance of "myClass"

///Constructor is a special function with the same name as the Class name and it returns Nothing
var demo = MyClass(); //Storing class Object in the variable named "name" here
// demo.printName("WsCube Tech"); //Calling the function & "WsCube Tech" is in function Argument
// demo.printName("Welcome to India");
// demo.printName("Thank you!!");
// demo.printName("Raman");
// demo.printName("Ramanujan");
// print(demo.a); //Accessing class variable using class Instance
// print(demo.Add());

// print(demo.sub(20, 8));
// print(demo.sub(40, 100));
}
class MyClass {

///By default, When the class is created at that time Constructor will automatically created and while Run-Time when the class
///object is created at that time Constructor will automatically call that means it will give us Object by constructing

MyClass() { // Default Constructor
print("myClass Object Created!!"); //This is init Block of the class
}

int a = 10;
void printName(String name) { //function Declaration and "String name" is in function Parameter
print(name); //function Definition where the Logic is Build
}

int Add() {
int a, b;
a = 5;
b = 6;
int sum = a + b;
return sum;
}

int sub(int x, int y) {
int sub = x - y;
return sub;
}

//1
// 2
// 3 //console Output
// 4
// 5
// 6
// 7
// 8
// 9
// 10
// 11
// int play(int m,int n) {
//
// }
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter