This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
// ==================BASIC USAGE | |
// A bool variable can have two values: true or false. | |
bool isDartFun = true; | |
bool isProgrammingEasy = false; | |
bool isRaining = false; | |
bool isSunny = true; | |
// ==================BOOLEAN PROPERTIES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
// ==================BASIC USAGE 1. | |
// Creating a list of integers | |
List<int> numbers = [1, 2, 3, 4, 5]; | |
// Creating a list of strings | |
List<String> fruits = ['apple', 'banana', 'cherry']; | |
// Adding elements to a list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
// Creating a map of key-value pairs (int to String) | |
Map<int, String> studentData = { | |
3620301111: 'Ololade', | |
3620302222: 'Chukwuemeka', | |
3620303333: 'Umar', | |
}; | |
// Accessing values using keys | |
String ololadeName = studentData[3620301111]!; // 'Ololade' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EachTitledNameModel{ | |
String? letterTitle; | |
List<String>? nameList=[]; | |
EachTitledNameModel ({this.letterTitle, this.nameList}); | |
} | |
List<EachTitledNameModel> getNameTitlesWithNames(List<String> nameList){ | |
List<EachTitledNameModel> sortedNameWithTitle = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EachTitledNameModel{ | |
String? letterTitle; | |
List<String>? nameList=[]; | |
EachTitledNameModel ({this.letterTitle, this.nameList}); | |
} | |
List<EachTitledNameModel> getNameTitlesWithNames(List<String> nameList){ | |
List<EachTitledNameModel> sortedNameWithTitle = []; | |
nameList.sort(); | |
for(int i = 0; i<nameList.length; i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
getNameTitlesWithNames(childNames).forEach((e){ | |
print("\n${e.letterTitle!}"); | |
print(e.nameList); | |
}); | |
} | |
class EachTitledNameModel{ | |
String? letterTitle; | |
List<String>? nameList=[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
getNameTitlesWithNames(childNames).forEach((e){ | |
print("\n${e.letterTitle!}"); | |
print(e.nameList); | |
}); | |
} | |
class EachTitledNameModel{ | |
String? letterTitle; | |
List<String>? nameList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========= SYNTAX | |
class ClassName { | |
// properties or attributes... | |
//... | |
// methods or functions... | |
} | |
//======== EXAMPLE | |
//======== EXAMPLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student { | |
// ========== Properties (Attributes of a stident) | |
String? name, department; | |
int? age, matricNumber; | |
double? gpa; | |
// ========== Methods (Actions a student can do) | |
// Methods 1: switchDepartment | |
void switchDepartment(String newDepartment) { | |
department = newDepartment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee { | |
String? name; | |
int? age; | |
String? department; | |
double? salary; | |
// Constructor | |
Employee(String name, int age, String department, double salary) { | |
this.name = name; | |
this.age = age; |