šŸ“¦ Project: Math Utils Package

šŸ“š Lesson 4: Packages & Libraries ā± 25-30 min šŸ“Š Intermediate
šŸŽÆ Objective

Create a reusable Dart package called math_utils that provides mathematical functions. You'll learn package creation, exports, and how to structure a library properly.

Requirements

  1. Create a package using dart create -t package math_utils
  2. Implement functions in lib/src/ (private implementation)
  3. Export only the public API from lib/math_utils.dart
  4. Include functions for: factorial, isPrime, gcd (greatest common divisor), lcm (least common multiple), and fibonacci
  5. Create a test application that imports and uses your package
  6. Add proper documentation comments

Package Structure

Structure
math_utils/
ā”œā”€ā”€ lib/
│   ā”œā”€ā”€ math_utils.dart          ← Public API (exports)
│   └── src/
│       ā”œā”€ā”€ arithmetic.dart      ← Core math functions
│       ā”œā”€ā”€ sequences.dart       ← Sequence generators
│       └── validation.dart      ← Validation functions
ā”œā”€ā”€ test/
│   └── math_utils_test.dart
└── pubspec.yaml