Skip to content

Instantly share code, notes, and snippets.

class BankAccount {
String accountNumber;
String accountHolder;
double _balance;
// Constructor
BankAccount(this.accountNumber, this.accountHolder, [double balance = 0.0])
: _balance = balance;
// Deposit money
class Contact {
String name;
String phoneNumber;
String email;
Contact({required this.name, required this.phoneNumber, required this.email});
@override
String toString() {
return 'Name: $name, Phone: $phoneNumber, Email: $email';
void main() {
List<String> students = [
'Angela', 'john', 'micheal', 'David', 'Destiny',
'Favour', 'Grace', 'james', 'mark', 'samuel'
];
class MathUtils {
// Calculate base raised to the given exponent (default is square)
static num power(num base, [num exponent = 2]) {
// Use math.pow from the dart:math library
return base == 0 && exponent == 0 ? 1 : math.pow(base, exponent);
}
// Calculate factorial of a non-negative integer
static int factorial(int n) {
if (n < 0) {
// Converts Celsius to Fahrenheit: °C × (9/5) + 32
double celsiusToFahrenheit(double celsius) {
return celsius * (9 / 5) + 32;
}
// Converts Fahrenheit to Celsius: (F - 32) × 5/9
double fahrenheitToCelsius(double fahrenheit) {
return (fahrenheit - 32) * 5 / 9;
}
void main() {
int n = 5;
// Pattern 1
for (int i = 1; i <= n; i++) {
String row = "";
for (int j = 1; j <= i; j++) {
row += "*";
}
print(row);