Skip to content

Instantly share code, notes, and snippets.

View mukhtharcm's full-sized avatar
🎯
Focusing

Muhammed Mukhthar CM mukhtharcm

🎯
Focusing
View GitHub Profile
// main.dart
import 'package:flutter/material.dart';
void main() {
runApp(const ZakatCalculatorApp());
}
class ZakatCalculatorApp extends StatelessWidget {
const ZakatCalculatorApp({super.key});
@mukhtharcm
mukhtharcm / main.dart
Created July 29, 2025 14:33
Day 3 Mini-Project Solution: Static "User Profile" Page
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@mukhtharcm
mukhtharcm / main.dart
Created July 29, 2025 14:33
Day 4 Mini-Project Solution: Interactive "Settings" Page
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@mukhtharcm
mukhtharcm / main.dart
Created July 29, 2025 14:28
Day 2 Mini-Project: Write a function that takes a List of int (e.g., student scores) and returns their average.
// This function calculates the average of a list of scores.
double calculateAverage(List<int> scores) {
if (scores.isEmpty) {
return 0; // Avoid division by zero if the list is empty.
}
int total = 0;
for (int score in scores) {
total = total + score;
}
@mukhtharcm
mukhtharcm / main.dart
Created July 29, 2025 14:27
Day 1 Mini-Project: Write a program in DartPad that checks if a person is old enough to vote.
void main() {
int userAge = 20;
int votingAge = 18;
print("Your age is: $userAge");
if (userAge >= votingAge) {
print("You are old enough to vote!");
} else {
print("You are not old enough to vote yet.");
@mukhtharcm
mukhtharcm / main.dart
Created July 29, 2025 14:01
Dart Basic: Functions
// A function is a named block of code that performs a task.
// This function takes two numbers and returns their sum.
double addNumbers(double num1, double num2) {
return num1 + num2;
}
// This is the main function where our program starts.
void main() {
double result = addNumbers(10.5, 20.0);
print("The result of the function is: $result");
@mukhtharcm
mukhtharcm / main.dart
Created July 29, 2025 13:35
Dart basics: Lists & For Loops
void main() {
// A List holds an ordered collection of items.
// The type of item is specified in the angle brackets < >.
// A List of Strings
List<String> shoppingList = ["Apples", "Milk", "Bread"];
print("Shopping List:");
for (String item in shoppingList) {
print("- $item");
}
@mukhtharcm
mukhtharcm / main.dart
Created July 29, 2025 13:25
Dart Basics: Conditionals
void main() {
double userWealth = 5000.0;
double nisab = 3000.0; // The minimum threshold for Zakat
print("Your wealth is: $userWealth");
print("The Nisab threshold is: $nisab");
// The 'if' statement checks if a condition is true.
if (userWealth > nisab) {
// This code runs ONLY if the condition is true.
@mukhtharcm
mukhtharcm / main.dart
Created July 29, 2025 13:23
Dart Basics: Math and comparisons
void main() {
int a = 10;
int b = 5;
// Math
print("a + b = ${a + b}"); // Addition
print("a - b = ${a - b}"); // Subtraction
print("a * b = ${a * b}"); // Multiplication
print("a / b = ${a / b}"); // Division
@mukhtharcm
mukhtharcm / main.dart
Created July 29, 2025 13:19
Dart Variables and Printing
void main() {
// Variables are like labeled boxes to store information.
// String: For text
String name = "Ahmed";
// int: For whole numbers
int age = 28;
// double: For numbers with decimals