├── README.md ├── higher ordeer function.dart ├── arrow function.dart ├── square find use arrow function.dart ├── lamda function.dart ├── even odd.dart ├── loop.dart ├── function.dart ├── leapyear.dart ├── condition.dart ├── abstraction.dart ├── polymorthism.dart ├── inheritance.dart ├── ans1.dart └── first.dart /README.md: -------------------------------------------------------------------------------- 1 | # Dart-Code-Basic -------------------------------------------------------------------------------- /higher ordeer function.dart: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /arrow function.dart: -------------------------------------------------------------------------------- 1 | var sum=(int a , int b) => a+b; 2 | void main( ){ 3 | print(sum(99,1)); 4 | } -------------------------------------------------------------------------------- /square find use arrow function.dart: -------------------------------------------------------------------------------- 1 | var squart=(int a) => a*a; 2 | void main( ){ 3 | print(squart(4)); 4 | } -------------------------------------------------------------------------------- /lamda function.dart: -------------------------------------------------------------------------------- 1 | //Lamda Function 2 | var sum =(int a , int b){ 3 | int c = a + b; 4 | return c; 5 | }; 6 | 7 | void main (){ 8 | print(sum(5,6)); 9 | } -------------------------------------------------------------------------------- /even odd.dart: -------------------------------------------------------------------------------- 1 | void main(){ 2 | int num =5; 3 | 4 | if(num % 2 ==0){ 5 | print("ODD number $num"); 6 | } 7 | else{ 8 | print("Even number"); 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /loop.dart: -------------------------------------------------------------------------------- 1 | void main(){ 2 | //LOOP work 3 | for(int i = 0 ; i <=10 ; i++){ 4 | print(i); 5 | } 6 | 7 | int i =0; 8 | while( i < 5) 9 | { 10 | print(i); 11 | i++; 12 | } 13 | } -------------------------------------------------------------------------------- /function.dart: -------------------------------------------------------------------------------- 1 | add (int a , int b){ 2 | int c = a + b; 3 | return c; 4 | } 5 | void main(){ 6 | int sum = add(5,10); 7 | print(sum); 8 | 9 | int sum2 =add(10,25); 10 | print(sum2); 11 | } -------------------------------------------------------------------------------- /leapyear.dart: -------------------------------------------------------------------------------- 1 | void main(){ 2 | int year = 2025; 3 | if ((year % 4 == 0 && year % 100 !=0 ) || (year % 400 == 0)) 4 | { 5 | print ("Leapyear year $year"); 6 | } 7 | else{ 8 | print("Not leapyear $year"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /condition.dart: -------------------------------------------------------------------------------- 1 | void main(){ 2 | // conditionals 3 | var age =25; 4 | if (age >18) 5 | { 6 | print("Adult"); 7 | } 8 | else{ 9 | print("Not adult"); 10 | } 11 | 12 | 13 | var decision= age >18 ? "Adult" : "Not adult" ; 14 | print(decision); 15 | } -------------------------------------------------------------------------------- /abstraction.dart: -------------------------------------------------------------------------------- 1 | abstract class Animal { 2 | void makeSound(); 3 | } 4 | 5 | class Dog extends Animal { 6 | @override 7 | void makeSound() { 8 | print("Bark"); 9 | } 10 | } 11 | 12 | class Cat extends Animal { 13 | @override 14 | void makeSound() { 15 | print("Meow"); 16 | } 17 | } 18 | 19 | void main() { 20 | Animal dog = Dog(); 21 | Animal cat = Cat(); 22 | 23 | dog.makeSound(); 24 | cat.makeSound(); 25 | } 26 | -------------------------------------------------------------------------------- /polymorthism.dart: -------------------------------------------------------------------------------- 1 | abstract class Animal { 2 | void makeSound(); 3 | } 4 | 5 | class Dog extends Animal { 6 | @override 7 | void makeSound() { 8 | print("Bark"); 9 | } 10 | } 11 | 12 | class Cat extends Animal { 13 | @override 14 | void makeSound() { 15 | print("Meow"); 16 | } 17 | } 18 | 19 | class Cow extends Animal { 20 | @override 21 | void makeSound() { 22 | print("Moo"); 23 | } 24 | } 25 | 26 | void makeAnimalSound(Animal animal) { 27 | animal.makeSound(); 28 | } 29 | 30 | void main() { 31 | Animal dog = Dog(); 32 | Animal cat = Cat(); 33 | Animal cow = Cow(); 34 | 35 | makeAnimalSound(dog); 36 | makeAnimalSound(cat); 37 | makeAnimalSound(cow); 38 | } 39 | -------------------------------------------------------------------------------- /inheritance.dart: -------------------------------------------------------------------------------- 1 | class Animal { 2 | void makeSound() { 3 | print("Animal sound"); 4 | } 5 | } 6 | 7 | class Dog extends Animal { 8 | @override 9 | void makeSound() { 10 | print("Bark"); 11 | } 12 | } 13 | 14 | class Cat extends Animal { 15 | @override 16 | void makeSound() { 17 | print("Meow"); 18 | } 19 | } 20 | 21 | class Cow extends Animal { 22 | @override 23 | void makeSound() { 24 | print("Moo"); 25 | } 26 | } 27 | 28 | void makeAnimalSound(Animal animal) { 29 | animal.makeSound(); 30 | } 31 | 32 | void main() { 33 | Animal dog = Dog(); 34 | Animal cat = Cat(); 35 | Animal cow = Cow(); 36 | 37 | makeAnimalSound(dog); 38 | makeAnimalSound(cat); 39 | makeAnimalSound(cow); 40 | } -------------------------------------------------------------------------------- /ans1.dart: -------------------------------------------------------------------------------- 1 | abstract class employee(){ 2 | String name =''; 3 | int id =0; 4 | double salary =0.0; 5 | int workhour =0; 6 | 7 | employee(this.name , this.id , this.salary , this.workhour); 8 | // increament part code work done 9 | void increament() 10 | 11 | } 12 | 13 | class admin extends employee{ 14 | admin(String name , int id , double salary , int workhour):super(name , id , salary , workhour) 15 | void increament(){ 16 | salary += salary *20 * workhour(500*workhour) 17 | } 18 | } 19 | class worker extends employee(){ 20 | 21 | } 22 | 23 | class display { 24 | print("") 25 | } 26 | 27 | void main(){ 28 | admin= jim admin("kasem" ,1002, 50000,500); 29 | exmployee= emp employee("jarif",10068 , 500 , 0.9); 30 | admin.increament(); 31 | emp.increament(); 32 | 33 | void catagory (){ 34 | if (salary > 5000){ 35 | print("Cat c"); 36 | } 37 | else{ 38 | print() 39 | } 40 | else if (salary > 6000)() 41 | print("Jarif ") 42 | } 43 | } -------------------------------------------------------------------------------- /first.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | int a = 5; 3 | int b = 6; 4 | 5 | //int c =a+b; 6 | // print(c); 7 | double x = 5.5; 8 | int c = a + x.truncate(); 9 | //print(c); 10 | 11 | String s = '5'; 12 | int v = a + int.parse(s); 13 | //print(v); 14 | 15 | String vv = a.toString() + s; 16 | //print(vv); 17 | 18 | String longString = 'Cat ' 19 | 'Bat ' 20 | 'Rat'; 21 | 22 | //print(longString); 23 | 24 | //const pi=3.1416; 25 | //pi =4.1416; 26 | final pi = 3.1416; 27 | //print(pi); 28 | 29 | final name = 'sajjad hossain jim'; 30 | //print(name); 31 | 32 | var z =2.5; 33 | var y = 3; 34 | var result = z + y; 35 | print("My result is $result"); 36 | 37 | print("My result ${ z + y}"); 38 | 39 | Collections 40 | List , set , map 41 | List lst = [1,2,3,4,5]; 42 | print(lst[0]); 43 | print(lst); 44 | 45 | lst.add(6); 46 | //print(lst); 47 | 48 | lst.addAll([9,10,11]); //append 49 | //print(lst); 50 | 51 | lst.insert(3, 99); 52 | print(lst); 53 | delete value 54 | lst.remove(99); 55 | print(lst); 56 | 57 | Dictionary --- Map {key value work} 58 | 59 | Map student = {90:"Sajjad JIM" , 91:"Mahfuj"}; 60 | print(student); 61 | 62 | print(student[90]); 63 | 64 | For in 65 | var num=[11,22,33,44,55,66,77]; 66 | for(int nums in num){ 67 | print(nums); 68 | } 69 | 70 | Function 71 | datatype name (parameter){ 72 | 73 | } 74 | 75 | } 76 | 77 | 78 | --------------------------------------------------------------------------------