zeba_academy_math
A lightweight and powerful Dart/Flutter mathematical utility package providing common mathematical helpers including arithmetic operations, clamping, interpolation, averages, percentages, rounding, and random number generation.
Features
✨ Simple arithmetic helpers ✨ Value clamping utilities ✨ Linear interpolation support ✨ Average calculations ✨ Percentage calculations ✨ Number rounding helpers ✨ Random integer and decimal generation ✨ Min / Max helpers ✨ Number checking utilities ✨ Lightweight and dependency-free
Installation
Add this package to your pubspec.yaml:
dependencies:
zeba_academy_math: ^1.0.0
Then run:
flutter pub get
Import
import 'package:zeba_academy_math/zeba_academy_math.dart';
Usage
Arithmetic Helpers
Perform common mathematical operations.
ZebaMathArithmetic.add(10, 20);
// 30
ZebaMathArithmetic.subtract(50, 20);
// 30
ZebaMathArithmetic.multiply(5, 5);
// 25
ZebaMathArithmetic.divide(100, 4);
// 25
Power Calculation
ZebaMathArithmetic.power(2, 3);
// 8
Clamp Values
Keep numbers within a specific range.
ZebaClamp.clamp(
150,
0,
100,
);
// Output:
// 100
Example:
ZebaClamp.clamp(
50,
0,
100,
);
// Output:
// 50
Linear Interpolation
Interpolate smoothly between two values.
ZebaInterpolation.lerp(
0,
100,
0.5,
);
// Output:
// 50
Useful for:
- Animations
- Progress calculations
- Position transitions
Average Calculation
Calculate average values easily.
ZebaAverage.calculate(
[
10,
20,
30,
]
);
// Output:
// 20
Percentage Helpers
Calculate Percentage
ZebaPercentage.calculate(
25,
100,
);
// Output:
// 25
Calculate Value From Percentage
ZebaPercentage.of(
20,
500,
);
// Output:
// 100
Rounding Utilities
Round Decimal Values
ZebaRounding.round(
12.34567,
2,
);
// Output:
// 12.35
Floor
ZebaRounding.floor(
10.8,
);
// Output:
// 10
Ceiling
ZebaRounding.ceil(
10.2,
);
// Output:
// 11
Random Number Generation
Random Integer
ZebaRandom.integer(
1,
100,
);
Generates a random number between 1 and 100.
Random Double
ZebaRandom.doubleValue(
1.0,
10.0,
);
Math Helpers
Maximum Value
ZebaMathHelpers.max(
10,
20,
);
// Output:
// 20
Minimum Value
ZebaMathHelpers.min(
10,
20,
);
// Output:
// 10
Check Even Number
ZebaMathHelpers.isEven(
4,
);
// true
Check Odd Number
ZebaMathHelpers.isOdd(
5,
);
// true
Why zeba_academy_math?
Many Flutter applications require small mathematical operations repeatedly.
Instead of rewriting common logic, this package provides:
✅ Clean APIs ✅ Reusable utilities ✅ No external dependencies ✅ Easy integration ✅ Production-friendly Dart code
Example
import 'package:zeba_academy_math/zeba_academy_math.dart';
void main(){
print(
ZebaMathArithmetic.add(
10,
20,
)
);
print(
ZebaPercentage.calculate(
50,
200,
)
);
print(
ZebaRandom.integer(
1,
100,
)
);
}
Roadmap
Future improvements may include:
- Advanced mathematical functions
- Statistics helpers
- Geometry utilities
- Trigonometry helpers
- Financial calculations
- More extension methods
Contributing
Contributions are welcome!
Steps:
- Fork the repository
- Create a new branch
- Add your improvements
- Commit changes
- Create a Pull Request
About Me
✨ I’m Sufyan bin Uzayr, an open-source developer passionate about building and sharing meaningful projects.
You can learn more about me and my work at:
or connect with me on:
Your all-in-one learning hub!
🚀 Explore courses and resources in coding, tech, and development at:
Empower yourself with practical skills through curated tutorials, real-world projects, and hands-on experience.
Level up your tech game today! 💻✨
Zeba Academy
Zeba Academy is a learning platform dedicated to coding, technology, and development.
➡ Visit our main site:
➡ Explore hands-on courses and resources:
➡ Check out our YouTube tutorials:
https://www.youtube.com/@zeba.academy
➡ Follow us on Instagram:
https://www.instagram.com/zeba.academy/
Thank you for visiting!
License
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).
You are free to:
- Use this software
- Study the source code
- Modify the software
- Share improvements
See the full license: