Skip to content

Instantly share code, notes, and snippets.

View abdorll's full-sized avatar
🧑‍💻
Coding...

Abdullah Opadeji abdorll

🧑‍💻
Coding...
View GitHub Profile
@abdorll
abdorll / main.dart
Last active October 11, 2023 20:16
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
@abdorll
abdorll / main.dart
Last active December 3, 2023 13:52
List in dart example
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
@abdorll
abdorll / main.dart
Last active December 3, 2023 14:06
Map in dart example
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'
class EachTitledNameModel{
String? letterTitle;
List<String>? nameList=[];
EachTitledNameModel ({this.letterTitle, this.nameList});
}
List<EachTitledNameModel> getNameTitlesWithNames(List<String> nameList){
List<EachTitledNameModel> sortedNameWithTitle = [];
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++){
void main() {
getNameTitlesWithNames(childNames).forEach((e){
print("\n${e.letterTitle!}");
print(e.nameList);
});
}
class EachTitledNameModel{
String? letterTitle;
List<String>? nameList=[];
@abdorll
abdorll / main.dart
Last active October 13, 2023 12:25
sort list of names with title
void main() {
getNameTitlesWithNames(childNames).forEach((e){
print("\n${e.letterTitle!}");
print(e.nameList);
});
}
class EachTitledNameModel{
String? letterTitle;
List<String>? nameList;
// ========= SYNTAX
class ClassName {
// properties or attributes...
//...
// methods or functions...
}
//======== EXAMPLE
//======== EXAMPLE
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;
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;