my_math 0.0.2
my_math: ^0.0.2 copied to clipboard
A simple Dart/Flutter package providing basic math operations such as addition, subtraction, multiplication, and division.
example/main.dart
import 'package:my_math/my_math.dart';
void main() {
final math = MyMath();
int a = 10;
int b = 5;
print('Add: ${math.add(a, b)}'); // Output: Add: 15
print('Subtract: ${math.subtract(a, b)}'); // Output: Subtract: 5
print('Multiply: ${math.multiply(a, b)}'); // Output: Multiply: 50
print('Divide: ${math.divide(a, b)}'); // Output: Divide: 2.0
try {
print('Divide by zero: ${math.divide(a, 0)}'); // This will throw an error
} catch (e) {
print('Error: $e'); // Output: Error: Cannot divide by zero
}
}