├── LICENSE ├── README.md ├── [2] Basics ├── Arithmetic Operators │ └── main.dart ├── Assignment Operators │ └── main.dart ├── Bitwise Operators │ └── main.dart ├── Boolean │ └── main.dart ├── Comments │ └── main.dart ├── Console Input │ └── main.dart ├── Data Types │ └── main.dart ├── Final & Constant Variables │ └── main.dart ├── Logical Operators │ └── main.dart ├── Numbers │ └── main.dart ├── Print Variables Inside Of A String │ └── main.dart ├── Printing To The Console │ └── main.dart ├── Relational Operators │ └── main.dart ├── Static vs Dynamic Variables │ └── main.dart ├── Strings │ └── main.dart ├── Type Test Operators │ └── main.dart └── Variables │ └── main.dart ├── [3] Control Flow ├── Break Statement │ └── main.dart ├── Conditional Expressions │ └── main.dart ├── Conditional if Statement │ └── main.dart ├── Continue Statement │ └── main.dart ├── Labels │ └── main.dart ├── Switch Statement │ └── main.dart ├── do while Loop │ └── main.dart ├── for Loop │ └── main.dart ├── for in Loop │ └── main.dart └── while Loop │ └── main.dart ├── [4] Functions ├── Basic Function │ └── main.dart ├── Function Optional Named Parameter │ └── main.dart ├── Function Optional Parameters with Default Values │ └── main.dart ├── Function Optional Positional Parameter │ └── main.dart ├── Function Parameters │ └── main.dart ├── Function Recursion │ └── main.dart ├── Function Return Values │ └── main.dart └── Lambda Function │ └── main.dart ├── [5] Error:Exception Handling ├── Custom Exception │ └── main.dart ├── Finally Block │ └── main.dart ├── Manually Throw An Exception │ └── main.dart ├── Try Catch Block │ └── main.dart ├── Try On Block │ └── main.dart └── Try On Catch Block │ └── main.dart ├── [6] Collections ├── Enumeration │ └── main.dart ├── Generics │ └── main.dart ├── HashMap │ └── main.dart ├── HashSet │ └── main.dart ├── Iterating Over Collections │ └── main.dart ├── Lists │ └── main.dart ├── Maps │ └── main.dart ├── Queue │ └── main.dart └── Set │ └── main.dart ├── [7] Classes & Objects ├── Abstract Classes │ └── main.dart ├── Basic Example │ └── main.dart ├── Cascade Operator │ └── main.dart ├── Constructor │ └── main.dart ├── Custom Getters & Setters │ └── main.dart ├── Inheritance │ └── main.dart ├── Method Overriding │ └── main.dart ├── Multiple Class Inheritance │ └── main.dart ├── Named Constructors │ └── main.dart ├── Static Keyword │ └── main.dart ├── Super Keyword │ └── main.dart └── this Keyword │ └── main.dart └── [8] Extras ├── Concurrency └── main.dart ├── Debugging └── main.dart ├── Libraries └── main.dart ├── Runes └── main.dart └── typedef └── main.dart /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dart Tutorials 2 | -------------------------------------------------------------------------------- /[2] Basics/Arithmetic Operators/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 10; 4 | int num2 = 5; 5 | 6 | // Addition + 7 | print(num1 + num2); 8 | 9 | // Subtraction - 10 | print(num1 - num2); 11 | 12 | // Multiplication * 13 | print(num1 * num2); 14 | 15 | // Division / 16 | print(num1 / num2); 17 | 18 | // Integer Division / 19 | print(num1 ~/ num2); 20 | 21 | // Modulo % 22 | print(num1 % num2); 23 | 24 | // Unary minus (negation) - 25 | print(-num1); 26 | 27 | // Increment ++ 28 | print(num1); 29 | num1++; // num1 = num1 + 1 or num1 += 1; 30 | print(num1); 31 | 32 | // Decrement -- 33 | print(num2); 34 | num2--; // num1 = num1 - 1 or num1 -= 1; 35 | print(num2); 36 | 37 | int numExtra = 8; 38 | 39 | print(++numExtra); 40 | print(numExtra); 41 | } 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /[2] Basics/Assignment Operators/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | // Assignment = 4 | int i = 20; 5 | 6 | // NULL only assignment ??= 7 | int j = 7; 8 | j ??= 10; 9 | //print(j); 10 | 11 | // Add assignment += 12 | int num1 = 10; 13 | //print(num1); 14 | num1 += 5; // num1 = num1 + 5; 15 | //print(num1); 16 | 17 | // Subtract assignment -= 18 | int num2 = 10; 19 | //print(num2); 20 | num2 -= 5; // num2 = num2 - 5; 21 | //print(num2); 22 | 23 | // Multiply assignment *= 24 | int num3 = 10; 25 | print(num3); 26 | num3 *= 5; // num3 = num3 * 5; 27 | print(num3); 28 | 29 | // Divide assignment /= 30 | double num4 = 10; 31 | print(num4); 32 | num4 /= 5; // num4 = num4 / 5; 33 | print(num4); 34 | } 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /[2] Basics/Bitwise Operators/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 55; 4 | int num2 = 78; 5 | 6 | // 128 64 32 16 8 4 2 1 7 | // 0 0 1 1 0 1 1 1 - 55 8 | // 0 1 0 0 1 1 1 0 - 78 9 | // ------------------------ 10 | // 0 1 1 1 1 0 0 1 11 | 12 | // Bitwise AND & 13 | print(num1 & num2); 14 | 15 | // Bitwise OR | 16 | print(num1 | num2); 17 | 18 | // Bitwise XOR ^ 19 | print(num1 ^ num2); 20 | 21 | // Bitwise NOT ~ 22 | //print(~num2); 23 | 24 | // Left Shift < 25 | print(num1 < 3); 26 | 27 | // Right Shift > 28 | print(num1 > 3); 29 | } 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /[2] Basics/Boolean/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | bool var1 = true; 4 | var1 = 670 > 89; 5 | 6 | print(var1); 7 | } -------------------------------------------------------------------------------- /[2] Basics/Comments/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | // This little code prints out some text 4 | /*print("Hello World"); 5 | print("Batman"); 6 | print("Batman"); 7 | print("Batman"); 8 | print("Batman");*/ 9 | } -------------------------------------------------------------------------------- /[2] Basics/Console Input/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | void main() 4 | { 5 | String str = stdin.readLineSync(); 6 | 7 | print(str); 8 | print("End of application"); 9 | } 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /[2] Basics/Data Types/main.dart: -------------------------------------------------------------------------------- 1 | int Epic() 2 | { 3 | return 1; 4 | } 5 | 6 | void main() 7 | { 8 | final v1 = Epic(); 9 | const v2 = 7; 10 | 11 | print(v1); 12 | print(v2); 13 | } -------------------------------------------------------------------------------- /[2] Basics/Final & Constant Variables/main.dart: -------------------------------------------------------------------------------- 1 | int Epic() 2 | { 3 | return 1; 4 | } 5 | 6 | void main() 7 | { 8 | final v1 = Epic(); 9 | const v2 = 7; 10 | 11 | print(v1); 12 | print(v2); 13 | } -------------------------------------------------------------------------------- /[2] Basics/Logical Operators/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 100; 4 | int num2 = 5; 5 | 6 | // AND && 7 | print(num1 > num2 && num1 < 20); 8 | 9 | // OR || 10 | print(num1 > num2 || num1 < 20); 11 | 12 | // NOT ! 13 | print(!(num1 > num2)); 14 | } 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /[2] Basics/Numbers/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | String str = "-5"; 4 | int i = num.parse(str); 5 | print(i); 6 | 7 | double d = num.parse("6.78"); 8 | print(d); 9 | 10 | print(d.round()); 11 | print(d.truncate()); 12 | print(i.isNegative); 13 | } -------------------------------------------------------------------------------- /[2] Basics/Print Variables Inside Of A String/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | var age = 90; 4 | var food = "Hello World $age"; 5 | 6 | print("I am $age and I love eating $food"); 7 | print(food); 8 | } -------------------------------------------------------------------------------- /[2] Basics/Printing To The Console/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | print("Hello World"); 4 | print("Another line"); 5 | } -------------------------------------------------------------------------------- /[2] Basics/Relational Operators/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 10; 4 | int num2 = 5; 5 | 6 | // Greater than > 7 | print(num1 > num2); 8 | 9 | // Less than < 10 | print(num1 < num2); 11 | 12 | // Greater than or equal to >= 13 | print(num1 >= num2); 14 | 15 | // Less than or equal to <= 16 | print(num1 <= num2); 17 | 18 | // Equal to == 19 | print(num1 == num2); 20 | 21 | // Not equal != 22 | print(num1 != num2); 23 | } 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /[2] Basics/Static vs Dynamic Variables/main.dart: -------------------------------------------------------------------------------- 1 | class Epic 2 | { 3 | var status = 0; 4 | static var staticS = 0; 5 | 6 | epicFun() 7 | { 8 | status++; 9 | staticS++; 10 | 11 | print('status: $status & staticS: $staticS'); 12 | } 13 | } 14 | 15 | void main() 16 | { 17 | print("E1"); 18 | 19 | Epic e = new Epic(); 20 | 21 | e.epicFun(); 22 | e.epicFun(); 23 | e.epicFun(); 24 | 25 | print("E2"); 26 | 27 | Epic e2 = new Epic(); 28 | 29 | e2.epicFun(); 30 | e2.epicFun(); 31 | e2.epicFun(); 32 | } -------------------------------------------------------------------------------- /[2] Basics/Strings/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | /*String str = "Y\"ou're"; 4 | print(str); 5 | 6 | String str2 = 'You\'re"hi"'; 7 | print(str2); 8 | 9 | String str3 = """Hello 10 | World"""; 11 | print(str3); 12 | 13 | String str4 = '''Hello 14 | Hi 15 | World'''; 16 | print(str4);*/ 17 | 18 | String name = "Batman"; 19 | 20 | String str1 = " Hello "; 21 | String str2 = "Wo${6 * 6}rl${name}d"; 22 | String result = str1 + str2; 23 | 24 | print(result); 25 | print(str1.length); 26 | print(str1.toLowerCase()); 27 | print(str1.toUpperCase()); 28 | print(str1.trim()); 29 | } -------------------------------------------------------------------------------- /[2] Basics/Type Test Operators/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int i = 10; 4 | 5 | // Is Type 6 | print(i is String); 7 | 8 | // Is Not Type 9 | print(i is! String); 10 | } 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /[2] Basics/Variables/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | //var epicName; 4 | //epicName = "Hello World"; 5 | 6 | var epicName = 90; 7 | epicName = 89; 8 | 9 | print(epicName); 10 | } -------------------------------------------------------------------------------- /[3] Control Flow/Break Statement/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | for (int i = 0; i <= 5; i++) 4 | { 5 | if (i == 3) 6 | { 7 | print("Before Break"); 8 | break; 9 | print("After Break"); 10 | } 11 | 12 | print(i * i); 13 | } 14 | 15 | print("Outside Of Loop"); 16 | } 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /[3] Control Flow/Conditional Expressions/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 900; 4 | 5 | var result = num1 < 100 ? "It is less than 100" : "It is more than 100"; 6 | 7 | print(result); 8 | 9 | int num2 = 7; 10 | 11 | var result2 = num2 ?? "It is null"; 12 | 13 | print(result2); 14 | } 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /[3] Control Flow/Conditional if Statement/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 900; 4 | 5 | var result = num1 < 100 ? "It is less than 100" : "It is more than 100"; 6 | 7 | print(result); 8 | 9 | int num2 = 7; 10 | 11 | var result2 = num2 ?? "It is null"; 12 | 13 | print(result2); 14 | } 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /[3] Control Flow/Continue Statement/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | outsideLoop: 4 | 5 | for (int x = 0; x <= 2; x++) 6 | { 7 | print("Loop $x"); 8 | 9 | for (int i = 0; i <= 5; i++) 10 | { 11 | if (i == 3) 12 | { 13 | break outsideLoop; 14 | } 15 | 16 | print(i * i); 17 | } 18 | } 19 | 20 | print("Outside Of Loop"); 21 | } 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /[3] Control Flow/Labels/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | for (int i = 0; i <= 5; i++) 4 | { 5 | if (i == 3) 6 | { 7 | print("Before Break"); 8 | continue; 9 | print("After Break"); 10 | } 11 | 12 | print(i * i); 13 | } 14 | 15 | print("Outside Of Loop"); 16 | } 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /[3] Control Flow/Switch Statement/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int x = 9; 4 | 5 | switch (x) 6 | { 7 | case 0: 8 | print("0"); 9 | break; 10 | 11 | case 1: 12 | print("1"); 13 | break; 14 | 15 | case 2: 16 | print("2"); 17 | break; 18 | 19 | case 3: 20 | print("3"); 21 | break; 22 | 23 | case 4: 24 | print("4"); 25 | break; 26 | 27 | case 5: 28 | print("5"); 29 | break; 30 | 31 | default: 32 | print("Default"); 33 | break; 34 | } 35 | 36 | 37 | /*if (x == 0) 38 | { 39 | print("Is 0"); 40 | } 41 | else if (x == 1) 42 | { 43 | print("Is 1"); 44 | } 45 | else if (x == 2) 46 | { 47 | print("Is 2"); 48 | } 49 | else if (x == 3) 50 | { 51 | print("Is 3"); 52 | } 53 | else if (x == 4) 54 | { 55 | print("Is 4"); 56 | } 57 | else if (x == 5) 58 | { 59 | print("Is 5"); 60 | } 61 | else 62 | { 63 | print("Default"); 64 | }*/ 65 | } 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /[3] Control Flow/do while Loop/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | /*int i = 10; 4 | 5 | while (i <= 5) 6 | { 7 | print(i * i); 8 | 9 | i++; 10 | }*/ 11 | 12 | int x = 10; 13 | 14 | do 15 | { 16 | print(x * x); 17 | 18 | x++; 19 | } 20 | while (x <= 5); 21 | } 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /[3] Control Flow/for Loop/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | for (int i = 0; i <= 100; i++) 4 | { 5 | print(i * i); 6 | } 7 | } 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /[3] Control Flow/for in Loop/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | var i = [1, 2, 3, 4, 67, 89, 0]; 4 | 5 | for (var val in i) 6 | { 7 | print(val); 8 | } 9 | } 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /[3] Control Flow/while Loop/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | /*for (int i = 0; i <= 100; i++) 4 | { 5 | print(i * i); 6 | }*/ 7 | 8 | int i = 0; 9 | 10 | while (i <= 100) 11 | { 12 | print(i * i); 13 | 14 | i++; 15 | } 16 | } 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /[4] Functions/Basic Function/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | EpicName(); 4 | } 5 | 6 | void EpicName() 7 | { 8 | print("Hello World"); 9 | } 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /[4] Functions/Function Optional Named Parameter/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | Add(5, num3: 7, num2: 8); 4 | } 5 | 6 | void Add(int num1, {int num2, int num3}) 7 | { 8 | //print(num1 + num2); 9 | print(num1); 10 | print(num2); 11 | print(num3); 12 | } 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /[4] Functions/Function Optional Parameters with Default Values/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | Add(5, num2: 8, num3: -7); 4 | } 5 | 6 | void Add(int num1, {int num2, int num3: 89}) 7 | { 8 | //print(num1 + num2); 9 | print(num1); 10 | print(num2); 11 | print(num3); 12 | } 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /[4] Functions/Function Optional Positional Parameter/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | Add(5, 7); 4 | Add(-9, 2); 5 | Add(99); 6 | } 7 | 8 | void Add(int num1, [int num2]) 9 | { 10 | //print(num1 + num2); 11 | print(num1); 12 | print(num2); 13 | } 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /[4] Functions/Function Parameters/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | Add(5, 7); 4 | Add(-9, 2); 5 | Add(99, 0); 6 | } 7 | 8 | void Add(int num1, int num2) 9 | { 10 | print(num1 + num2); 11 | } 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /[4] Functions/Function Recursion/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | // 5! = 5 * 4 * 3 * 2 * 1 = 120 4 | // 6! = 6 * 5 * 4 * 3 * 2 * 1 = 720 5 | 6 | int res = CalculateFactorial(10); 7 | 8 | print(res); 9 | } 10 | 11 | int CalculateFactorial(int n) 12 | { 13 | if (n <= 0) 14 | { 15 | return 1; 16 | } 17 | else 18 | { 19 | int result = (n * CalculateFactorial(n - 1)); 20 | 21 | return result; 22 | } 23 | } 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /[4] Functions/Function Return Values/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int result = Add(10, 9); 4 | 5 | print(result); 6 | print(result * result); 7 | } 8 | 9 | int Add(int num1, int num2) 10 | { 11 | return num1 + num2; 12 | } 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /[4] Functions/Lambda Function/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | Epic(); 4 | 5 | String res = EpicReturn(); 6 | 7 | print(res); 8 | } 9 | 10 | Epic() => print("We are epic"); 11 | 12 | String EpicReturn() => "Hi"; 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /[5] Error:Exception Handling/Custom Exception/main.dart: -------------------------------------------------------------------------------- 1 | class EpicException implements Exception 2 | { 3 | String errMsg() => "Epic Exception"; 4 | } 5 | 6 | void main() 7 | { 8 | int num1 = 100; 9 | int num2 = 5; 10 | 11 | try 12 | { 13 | if (num1 == 100) 14 | { 15 | throw new EpicException(); 16 | } 17 | else 18 | { 19 | print(num1 ~/ num2); 20 | } 21 | } 22 | on FormatException 23 | { 24 | print("Number cannot be 100"); 25 | } 26 | catch (error) 27 | { 28 | print(error); 29 | } 30 | finally 31 | { 32 | print("Finally"); 33 | } 34 | 35 | print("End of Application"); 36 | } 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /[5] Error:Exception Handling/Finally Block/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 10; 4 | int num2 = 0; 5 | 6 | try 7 | { 8 | print(num1 ~/ num2); 9 | } 10 | catch (error) 11 | { 12 | print(error); 13 | } 14 | finally 15 | { 16 | print("Finally"); 17 | } 18 | 19 | print("End of Application"); 20 | } 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /[5] Error:Exception Handling/Manually Throw An Exception/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 100; 4 | int num2 = 5; 5 | 6 | try 7 | { 8 | if (num1 == 100) 9 | { 10 | throw new FormatException(); 11 | } 12 | else 13 | { 14 | print(num1 ~/ num2); 15 | } 16 | } 17 | on FormatException 18 | { 19 | print("Number cannot be 100"); 20 | } 21 | catch (error) 22 | { 23 | print(error); 24 | } 25 | finally 26 | { 27 | print("Finally"); 28 | } 29 | 30 | print("End of Application"); 31 | } 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /[5] Error:Exception Handling/Try Catch Block/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 10; 4 | int num2 = 6; 5 | 6 | try 7 | { 8 | print(num1 ~/ num2); 9 | } 10 | catch (error) 11 | { 12 | print(error); 13 | } 14 | 15 | print("End of Application"); 16 | } 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /[5] Error:Exception Handling/Try On Block/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 10; 4 | int num2 = 0; 5 | 6 | try 7 | { 8 | print(num1 ~/ num2); 9 | } 10 | on IntegerDivisionByZeroException 11 | { 12 | print("Cannot divide by zero"); 13 | } 14 | 15 | print("End of Application"); 16 | } 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /[5] Error:Exception Handling/Try On Catch Block/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int num1 = 10; 4 | int num2 = 5; 5 | 6 | String pi = "3.14159"; 7 | 8 | try 9 | { 10 | print(num1 ~/ num2); 11 | 12 | double number = double.parse(pi); 13 | print($(number * number)); 14 | } 15 | on IntegerDivisionByZeroException 16 | { 17 | print("Cannot divide by zero"); 18 | } 19 | catch (error) 20 | { 21 | print("Catch block: $error"); 22 | } 23 | 24 | print("End of Application"); 25 | } 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /[6] Collections/Enumeration/main.dart: -------------------------------------------------------------------------------- 1 | enum SuperHeroes 2 | { 3 | Yoda, 4 | Batman, 5 | Superman, 6 | Lantern 7 | } 8 | 9 | void main() 10 | { 11 | print(SuperHeroes.Yoda.index); 12 | print(SuperHeroes.Batman.index); 13 | print(SuperHeroes.Superman.index); 14 | print(SuperHeroes.Lantern.index); 15 | } 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /[6] Collections/Generics/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | List epicList = new List (); 4 | epicList.add(1); 5 | epicList.add(2); 6 | epicList.add(3); 7 | epicList.add(4); 8 | epicList.add(67); 9 | 10 | print(epicList); 11 | } 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /[6] Collections/HashMap/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | void main() 4 | { 5 | var hashy = new HashMap(); 6 | 7 | hashy['key1'] = 10; 8 | hashy['key2'] = "Hello World"; 9 | 10 | print(hashy); 11 | print(hashy['key2']); 12 | } 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /[6] Collections/HashSet/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | void main() 4 | { 5 | Set epicSet = new HashSet(); 6 | 7 | epicSet.add(10); 8 | epicSet.add(20); 9 | epicSet.add(30); 10 | epicSet.add(40); 11 | epicSet.add(50); 12 | epicSet.add(10); 13 | 14 | print(epicSet); 15 | } 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /[6] Collections/Iterating Over Collections/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | List epicList = new List (); 4 | epicList.add(1); 5 | epicList.add(2); 6 | epicList.add(3); 7 | epicList.add(4); 8 | epicList.add(67); 9 | 10 | print(epicList); 11 | 12 | Iterator itr = epicList.iterator; 13 | 14 | while (itr.moveNext()) 15 | { 16 | int result = itr.current; 17 | print(result * result); 18 | } 19 | } 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /[6] Collections/Lists/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | var scores = new List(); 4 | 5 | /*scores[0] = 10; 6 | scores[1] = 20; 7 | scores[2] = 30; 8 | scores[3] = 40; 9 | scores[4] = 50;*/ 10 | 11 | scores.add(10); 12 | scores.add(20); 13 | scores.add(30); 14 | scores.add(40); 15 | scores.add(50); 16 | 17 | print(scores); 18 | print(scores[1]); 19 | 20 | for (int i = 0; i < scores.length; i++) 21 | { 22 | print(scores[i]); 23 | } 24 | } 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /[6] Collections/Maps/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | //var epicMap = {'Key1':345, 'Key2':'EpicValue'}; 4 | var epicMap = new Map(); 5 | 6 | epicMap['Key3'] = 67; 7 | 8 | print(epicMap); 9 | print(epicMap['Key2']); 10 | 11 | epicMap.forEach((key, value) => print("$key and $value")); 12 | } 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /[6] Collections/Queue/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | void main() 4 | { 5 | // FIFO (First In First Out) 6 | 7 | Queue q = new Queue(); 8 | q.add(1); 9 | q.add(2); 10 | q.add(3); 11 | q.add(4); 12 | q.add(5); 13 | 14 | print(q); 15 | 16 | q.addFirst(23); 17 | q.addLast(90); 18 | 19 | print(q); 20 | } 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /[6] Collections/Set/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | Set epicSet = new Set(); 4 | 5 | epicSet.add(10); 6 | epicSet.add(20); 7 | epicSet.add(30); 8 | epicSet.add(40); 9 | epicSet.add(50); 10 | epicSet.add(10); 11 | 12 | print(epicSet); 13 | 14 | for (var value in epicSet) 15 | { 16 | print(value); 17 | } 18 | 19 | Set epicSet2 = new Set.from([1, 2, 3, 4]); 20 | 21 | print(epicSet2); 22 | } 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Abstract Classes/main.dart: -------------------------------------------------------------------------------- 1 | abstract class Vehicle 2 | { 3 | Vehicle() 4 | { 5 | print("Hi"); 6 | } 7 | 8 | void Drive() 9 | { 10 | print("Drive drive drive"); 11 | } 12 | 13 | int _maxSpeed = 60; 14 | 15 | void set maxSpeed(int speed) 16 | { 17 | _maxSpeed = speed * 2; 18 | } 19 | 20 | int get maxSpeed 21 | { 22 | return _maxSpeed; 23 | } 24 | } 25 | 26 | class Car implements Vehicle 27 | { 28 | Car() 29 | { 30 | print("Custom constructor"); 31 | } 32 | 33 | @override 34 | void Drive() 35 | { 36 | print("New Drive"); 37 | } 38 | 39 | void Hello() 40 | { 41 | print("Hello, I am a Car"); 42 | } 43 | } 44 | 45 | void main() 46 | { 47 | /*Vehicle v1 = new Vehicle(100); 48 | Vehicle v2 = new Vehicle.empty(); 49 | 50 | v1.Drive(); 51 | print(v1.maxSpeed); 52 | v1.maxSpeed = 89; 53 | print(v1.maxSpeed); 54 | 55 | print(v2.maxSpeed);*/ 56 | 57 | Car c1 = new Car(); 58 | 59 | c1.Drive(); 60 | print(c1.maxSpeed); 61 | c1.maxSpeed = 10; 62 | print(c1.maxSpeed); 63 | c1.Hello(); 64 | } 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Basic Example/main.dart: -------------------------------------------------------------------------------- 1 | class Vehicle 2 | { 3 | void Drive() 4 | { 5 | print("Drive drive drive"); 6 | } 7 | 8 | int maxSpeed = 60; 9 | } 10 | 11 | void main() 12 | { 13 | Vehicle v1 = new Vehicle(); 14 | Vehicle v2 = new Vehicle(); 15 | 16 | v1.Drive(); 17 | print(v1.maxSpeed); 18 | v1.maxSpeed = 100; 19 | print(v1.maxSpeed); 20 | 21 | print(v2.maxSpeed); 22 | } 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Cascade Operator/main.dart: -------------------------------------------------------------------------------- 1 | abstract class Vehicle 2 | { 3 | Vehicle() 4 | { 5 | print("Hi"); 6 | } 7 | 8 | void Drive() 9 | { 10 | print("Drive drive drive"); 11 | } 12 | } 13 | 14 | class Car extends Vehicle 15 | { 16 | Car() 17 | { 18 | print("Custom constructor"); 19 | } 20 | 21 | @override 22 | void Drive() 23 | { 24 | super.Drive(); 25 | print("New Drive"); 26 | } 27 | 28 | void Hello() 29 | { 30 | print("Hello, I am a Car"); 31 | } 32 | 33 | static int _maxSpeed = 60; 34 | } 35 | 36 | void main() 37 | { 38 | /*Vehicle v1 = new Vehicle(100); 39 | Vehicle v2 = new Vehicle.empty(); 40 | 41 | v1.Drive(); 42 | print(v1.maxSpeed); 43 | v1.maxSpeed = 89; 44 | print(v1.maxSpeed); 45 | 46 | print(v2.maxSpeed);*/ 47 | 48 | Car c3 = new Car(); 49 | c3 50 | ..Drive() 51 | ..Hello() 52 | ..Drive() 53 | ..Hello(); 54 | } 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Constructor/main.dart: -------------------------------------------------------------------------------- 1 | class Vehicle 2 | { 3 | void Drive() 4 | { 5 | print("Drive drive drive"); 6 | } 7 | 8 | int maxSpeed = 60; 9 | } 10 | 11 | void main() 12 | { 13 | Vehicle v1 = new Vehicle(); 14 | Vehicle v2 = new Vehicle(); 15 | 16 | v1.Drive(); 17 | print(v1.maxSpeed); 18 | v1.maxSpeed = 100; 19 | print(v1.maxSpeed); 20 | 21 | print(v2.maxSpeed); 22 | } 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Custom Getters & Setters/main.dart: -------------------------------------------------------------------------------- 1 | class Vehicle 2 | { 3 | Vehicle(int speed) 4 | { 5 | print("Hi"); 6 | _maxSpeed = speed; 7 | } 8 | 9 | Vehicle.empty() 10 | { 11 | print("Named constructor"); 12 | } 13 | 14 | void Drive() 15 | { 16 | print("Drive drive drive"); 17 | } 18 | 19 | int _maxSpeed = 60; 20 | 21 | void set maxSpeed(int speed) 22 | { 23 | _maxSpeed = speed * 2; 24 | } 25 | 26 | int get maxSpeed 27 | { 28 | return _maxSpeed; 29 | } 30 | } 31 | 32 | void main() 33 | { 34 | Vehicle v1 = new Vehicle(100); 35 | Vehicle v2 = new Vehicle.empty(); 36 | 37 | v1.Drive(); 38 | print(v1.maxSpeed); 39 | v1.maxSpeed = 89; 40 | print(v1.maxSpeed); 41 | 42 | print(v2.maxSpeed); 43 | } 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Inheritance/main.dart: -------------------------------------------------------------------------------- 1 | class Vehicle 2 | { 3 | Vehicle() 4 | { 5 | print("Hi"); 6 | } 7 | 8 | void Drive() 9 | { 10 | print("Drive drive drive"); 11 | } 12 | 13 | int _maxSpeed = 60; 14 | 15 | void set maxSpeed(int speed) 16 | { 17 | _maxSpeed = speed * 2; 18 | } 19 | 20 | int get maxSpeed 21 | { 22 | return _maxSpeed; 23 | } 24 | } 25 | 26 | class Car extends Vehicle 27 | { 28 | Car() 29 | { 30 | print("Custom constructor"); 31 | } 32 | 33 | void Hello() 34 | { 35 | print("Hello, I am a Car"); 36 | } 37 | } 38 | 39 | void main() 40 | { 41 | /*Vehicle v1 = new Vehicle(100); 42 | Vehicle v2 = new Vehicle.empty(); 43 | 44 | v1.Drive(); 45 | print(v1.maxSpeed); 46 | v1.maxSpeed = 89; 47 | print(v1.maxSpeed); 48 | 49 | print(v2.maxSpeed);*/ 50 | 51 | Car c1 = new Car(); 52 | 53 | c1.Drive(); 54 | print(c1.maxSpeed); 55 | c1.maxSpeed = 10; 56 | print(c1.maxSpeed); 57 | c1.Hello(); 58 | 59 | } 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Method Overriding/main.dart: -------------------------------------------------------------------------------- 1 | class Vehicle 2 | { 3 | Vehicle() 4 | { 5 | print("Hi"); 6 | } 7 | 8 | void Drive() 9 | { 10 | print("Drive drive drive"); 11 | } 12 | 13 | int _maxSpeed = 60; 14 | 15 | void set maxSpeed(int speed) 16 | { 17 | _maxSpeed = speed * 2; 18 | } 19 | 20 | int get maxSpeed 21 | { 22 | return _maxSpeed; 23 | } 24 | } 25 | 26 | class Car extends Vehicle 27 | { 28 | Car() 29 | { 30 | print("Custom constructor"); 31 | } 32 | 33 | @override 34 | void Drive() 35 | { 36 | print("New Drive"); 37 | } 38 | 39 | void Hello() 40 | { 41 | print("Hello, I am a Car"); 42 | } 43 | } 44 | 45 | void main() 46 | { 47 | /*Vehicle v1 = new Vehicle(100); 48 | Vehicle v2 = new Vehicle.empty(); 49 | 50 | v1.Drive(); 51 | print(v1.maxSpeed); 52 | v1.maxSpeed = 89; 53 | print(v1.maxSpeed); 54 | 55 | print(v2.maxSpeed);*/ 56 | 57 | Car c1 = new Car(); 58 | 59 | c1.Drive(); 60 | print(c1.maxSpeed); 61 | c1.maxSpeed = 10; 62 | print(c1.maxSpeed); 63 | c1.Hello(); 64 | 65 | } 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Multiple Class Inheritance/main.dart: -------------------------------------------------------------------------------- 1 | abstract class Vehicle 2 | { 3 | Vehicle() 4 | { 5 | print("Hi"); 6 | } 7 | 8 | void Drive() 9 | { 10 | print("Drive drive drive"); 11 | } 12 | 13 | int _maxSpeed = 60; 14 | 15 | void set maxSpeed(int speed) 16 | { 17 | _maxSpeed = speed * 2; 18 | } 19 | 20 | int get maxSpeed 21 | { 22 | return _maxSpeed; 23 | } 24 | } 25 | 26 | class Car extends Vehicle 27 | { 28 | Car() 29 | { 30 | print("Custom constructor"); 31 | } 32 | 33 | @override 34 | void Drive() 35 | { 36 | print("New Drive"); 37 | } 38 | 39 | void Hello() 40 | { 41 | print("Hello, I am a Car"); 42 | } 43 | } 44 | 45 | class BMW extends Car 46 | { 47 | void Hey() 48 | { 49 | print("Grandchild class"); 50 | } 51 | } 52 | 53 | void main() 54 | { 55 | /*Vehicle v1 = new Vehicle(100); 56 | Vehicle v2 = new Vehicle.empty(); 57 | 58 | v1.Drive(); 59 | print(v1.maxSpeed); 60 | v1.maxSpeed = 89; 61 | print(v1.maxSpeed); 62 | 63 | print(v2.maxSpeed);*/ 64 | 65 | /*Car c1 = new Car(); 66 | 67 | c1.Drive(); 68 | print(c1.maxSpeed); 69 | c1.maxSpeed = 10; 70 | print(c1.maxSpeed); 71 | c1.Hello();*/ 72 | 73 | BMW b1 = new BMW(); 74 | b1.Hey(); 75 | b1.Drive(); 76 | } 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Named Constructors/main.dart: -------------------------------------------------------------------------------- 1 | class Vehicle 2 | { 3 | Vehicle(int speed) 4 | { 5 | print("Hi"); 6 | maxSpeed = speed; 7 | } 8 | 9 | Vehicle.empty() 10 | { 11 | print("Named constructor"); 12 | } 13 | 14 | void Drive() 15 | { 16 | print("Drive drive drive"); 17 | } 18 | 19 | int maxSpeed = 60; 20 | } 21 | 22 | void main() 23 | { 24 | Vehicle v1 = new Vehicle(100); 25 | Vehicle v2 = new Vehicle.empty(); 26 | 27 | v1.Drive(); 28 | print(v1.maxSpeed); 29 | v1.maxSpeed = 89; 30 | print(v1.maxSpeed); 31 | 32 | print(v2.maxSpeed); 33 | } 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Static Keyword/main.dart: -------------------------------------------------------------------------------- 1 | abstract class Vehicle 2 | { 3 | Vehicle() 4 | { 5 | print("Hi"); 6 | } 7 | 8 | void Drive() 9 | { 10 | print("Drive drive drive"); 11 | } 12 | } 13 | 14 | class Car extends Vehicle 15 | { 16 | Car() 17 | { 18 | print("Custom constructor"); 19 | } 20 | 21 | @override 22 | void Drive() 23 | { 24 | print("New Drive"); 25 | } 26 | 27 | void Hello() 28 | { 29 | print("Hello, I am a Car"); 30 | } 31 | 32 | static int _maxSpeed = 60; 33 | } 34 | 35 | void main() 36 | { 37 | /*Vehicle v1 = new Vehicle(100); 38 | Vehicle v2 = new Vehicle.empty(); 39 | 40 | v1.Drive(); 41 | print(v1.maxSpeed); 42 | v1.maxSpeed = 89; 43 | print(v1.maxSpeed); 44 | 45 | print(v2.maxSpeed);*/ 46 | 47 | Car c1 = new Car(); 48 | 49 | c1.Drive(); 50 | print(Car._maxSpeed); 51 | Car._maxSpeed = 10; 52 | print(Car._maxSpeed); 53 | c1.Hello(); 54 | 55 | Car c2 = new Car(); 56 | print(Car._maxSpeed); 57 | } 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /[7] Classes & Objects/Super Keyword/main.dart: -------------------------------------------------------------------------------- 1 | abstract class Vehicle 2 | { 3 | Vehicle() 4 | { 5 | print("Hi"); 6 | } 7 | 8 | void Drive() 9 | { 10 | print("Drive drive drive"); 11 | } 12 | } 13 | 14 | class Car extends Vehicle 15 | { 16 | Car() 17 | { 18 | print("Custom constructor"); 19 | } 20 | 21 | @override 22 | void Drive() 23 | { 24 | super.Drive(); 25 | print("New Drive"); 26 | } 27 | 28 | void Hello() 29 | { 30 | print("Hello, I am a Car"); 31 | } 32 | 33 | static int _maxSpeed = 60; 34 | } 35 | 36 | void main() 37 | { 38 | /*Vehicle v1 = new Vehicle(100); 39 | Vehicle v2 = new Vehicle.empty(); 40 | 41 | v1.Drive(); 42 | print(v1.maxSpeed); 43 | v1.maxSpeed = 89; 44 | print(v1.maxSpeed); 45 | 46 | print(v2.maxSpeed);*/ 47 | 48 | Car c1 = new Car(); 49 | 50 | c1.Drive(); 51 | print(Car._maxSpeed); 52 | Car._maxSpeed = 10; 53 | print(Car._maxSpeed); 54 | c1.Hello(); 55 | 56 | Car c2 = new Car(); 57 | print(Car._maxSpeed); 58 | } 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /[7] Classes & Objects/this Keyword/main.dart: -------------------------------------------------------------------------------- 1 | abstract class Vehicle 2 | { 3 | Vehicle() 4 | { 5 | print("Hi"); 6 | } 7 | 8 | void Drive() 9 | { 10 | print("Drive drive drive"); 11 | } 12 | 13 | int _maxSpeed = 60; 14 | 15 | void set maxSpeed(int _maxSpeed) 16 | { 17 | this._maxSpeed = _maxSpeed * 2; 18 | } 19 | 20 | int get maxSpeed 21 | { 22 | return _maxSpeed; 23 | } 24 | } 25 | 26 | class Car extends Vehicle 27 | { 28 | Car() 29 | { 30 | print("Custom constructor"); 31 | } 32 | 33 | @override 34 | void Drive() 35 | { 36 | print("New Drive"); 37 | } 38 | 39 | void Hello() 40 | { 41 | print("Hello, I am a Car"); 42 | } 43 | } 44 | 45 | void main() 46 | { 47 | /*Vehicle v1 = new Vehicle(100); 48 | Vehicle v2 = new Vehicle.empty(); 49 | 50 | v1.Drive(); 51 | print(v1.maxSpeed); 52 | v1.maxSpeed = 89; 53 | print(v1.maxSpeed); 54 | 55 | print(v2.maxSpeed);*/ 56 | 57 | Car c1 = new Car(); 58 | 59 | c1.Drive(); 60 | print(c1.maxSpeed); 61 | c1.maxSpeed = 10; 62 | print(c1.maxSpeed); 63 | c1.Hello(); 64 | } 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /[8] Extras/Concurrency/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:isolate'; 2 | 3 | void Func(String str) 4 | { 5 | print(str); 6 | } 7 | 8 | void main() 9 | { 10 | Isolate.spawn(Func, "1"); 11 | Isolate.spawn(Func, "2"); 12 | Isolate.spawn(Func, "3"); 13 | Isolate.spawn(Func, "4"); 14 | Isolate.spawn(Func, "5"); 15 | Isolate.spawn(Func, "6"); 16 | 17 | print("Normal 1"); 18 | print("Normal 2"); 19 | print("Normal 3"); 20 | print("Normal 4"); 21 | print("Normal 5"); 22 | print("Normal 6"); 23 | } 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /[8] Extras/Debugging/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int x = 10; 4 | int y = 20; 5 | 6 | y = 90; 7 | 8 | print(x * y); 9 | } -------------------------------------------------------------------------------- /[8] Extras/Libraries/main.dart: -------------------------------------------------------------------------------- 1 | library custom_lib; 2 | import 'dart:math'; 3 | 4 | void main() 5 | { 6 | int i = 9; 7 | print(sqrt(i)); 8 | } 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /[8] Extras/Runes/main.dart: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | String epicString = "Hello World"; 4 | print(epicString.codeUnits); 5 | print(epicString.codeUnitAt(1)); 6 | } 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /[8] Extras/typedef/main.dart: -------------------------------------------------------------------------------- 1 | typedef Operator(int num1, int num2); 2 | 3 | Addition(int num1, int num2) 4 | { 5 | print(num1 + num2); 6 | } 7 | 8 | Subtraction(int num1, int num2) 9 | { 10 | print(num1 - num2); 11 | } 12 | 13 | Multiplication(int num1, int num2) 14 | { 15 | print(num1 * num2); 16 | } 17 | 18 | Division(int num1, int num2) 19 | { 20 | print(num1 / num2); 21 | } 22 | 23 | Calculation(int num1, int num2, Operator opAlias) 24 | { 25 | opAlias(num1, num2); 26 | } 27 | 28 | void main() 29 | { 30 | /*Addition(10, 5); 31 | Subtraction(10, 5); 32 | Multiplication(10, 5); 33 | Division(10, 5);*/ 34 | 35 | Operator op = Addition; 36 | op(90, 80); 37 | 38 | op = Multiplication; 39 | op(10, 8); 40 | } 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | --------------------------------------------------------------------------------