Skip to content

Instantly share code, notes, and snippets.

@mukhtharcm
Created July 29, 2025 14:01
Show Gist options
  • Save mukhtharcm/1e4cc5611bce9ca50fabdc646d28bc02 to your computer and use it in GitHub Desktop.
Save mukhtharcm/1e4cc5611bce9ca50fabdc646d28bc02 to your computer and use it in GitHub Desktop.
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");
double zakatableAssets = 15000;
double liabilities = 4000;
// Functions make code reusable and easier to read.
double netWealth = calculateNetWealth(zakatableAssets, liabilities);
print("Your net zakatable wealth is: $netWealth");
}
// A function to calculate net wealth.
double calculateNetWealth(double assets, double debts) {
// The 'return' keyword sends a value back from the function.
return assets - debts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment