How wasifibnharun/bmi-calculator-app works
Purpose and Runtime
A standalone Flutter Android BMI calculator. It accepts height in centimeters and weight in kilograms, computes BMI locally, classifies the result, and presents it with animated UI. There is no backend, persistence layer, authentication, or external API; the only named package integration is gauge_indicator.
Primary Dart runtime entry point: lib/main.dart. Android embeds the Flutter runtime through android/app/src/main/kotlin/com/bmi/calculator/bmi_calculator/MainActivity.kt.
Application Bootstrap and Navigation
lib/main.dart initializes the Material 3 application, global theme/color usage, and initial route/widget. The app begins at the animated splash screen, which transitions with replacement navigation to the calculator, preventing return to splash via back navigation.
Core paths:
• lib/main.dart
• lib/screens/splash_screen.dart
• lib/core/colors/app_colors.dart
Splash Stage
SplashScreen is a stateful, animation-driven entry stage. It owns an AnimationController via SingleTickerProviderStateMixin and combines fade/scale animation before invoking Navigator.pushReplacement to enter the calculator flow.
Boundary: splash owns only timed visual entry and navigation; BMI input/result state begins after the destination calculator screen is created.
Core path:
• lib/screens/splash_screen.dart
Calculator State and Domain Flow
BmiCalculatorScreen is the central state owner. It coordinates input values, form validation, calculated BMI, derived category, and reset behavior using StatefulWidget/setState.
Primary control flow:
1. User enters height and weight.
2. Form validation rejects empty or invalid values inline.
3. Screen converts cm to meters and computes weightKg / heightMeters².
4. BMI thresholds derive Underweight, Normal, Overweight, or Obese plus a category color.
5. Updated state renders the result card and reference legend.
6. Reset clears form fields and result state.
Core path:
• lib/screens/bmi_calculator_screen.dart
Input Boundary
The input component encapsulates height/weight field presentation and validation feedback, while the calculator screen retains submission, calculation, and result-state authority. This separates raw text/form concerns from BMI business decisions.
Core paths:
• lib/widgets/input_card.dart
• lib/screens/bmi_calculator_screen.dart
Result Visualization
ResultCard converts calculated state into the user-facing BMI score, category badge, and radial gauge. The gauge is animated and implemented through the external gauge_indicator Flutter package. It should receive already-calculated BMI/category data rather than recalculate domain logic.
Core paths:
• lib/widgets/result_card.dart
• lib/screens/bmi_calculator_screen.dart
• pubspec.yaml
Shared Visual Semantics
The centralized palette supplies application and BMI-category colors, ensuring calculator classification, result badge/gauge, and legend can use consistent visual semantics. The reference table is a static explanation of the same category thresholds/colors, always visible in the calculator UI.
Core paths:
• lib/core/colors/app_colors.dart
• lib/widgets/bmi_reference_table.dart
• lib/widgets/result_card.dart
Platform and Build Boundary
Flutter/Dart contains application behavior and UI. The Android Gradle project packages it as an Android app, with manifest and native launcher integration; it does not contain BMI logic.
Core paths:
• android/app/src/main/AndroidManifest.xml
• android/app/src/main/kotlin/com/bmi/calculator/bmi_calculator/MainActivity.kt
• android/app/build.gradle.kts
Main entry points: bmi_calculator_screen.dart BMI calculator · app_colors.dart App colors · main.dart App bootstrap · result_card.dart Result card
Components 13
Flutter application
Local BMI calculation and animated UI.
- App bootstrap · Initializes Material 3 theme and starts the splash screen.
lib/main.dart - App colors · Defines application and BMI-category colors.
lib/core/colors/app_colors.dart - Splash screen · Owns timed fade/scale animation and replacement navigation.
lib/screens/splash_screen.dart - BMI calculator · Owns form submission, BMI state, classification, and reset.
lib/screens/bmi_calculator_screen.dart - Input card · Presents height and weight fields with validation feedback.
lib/widgets/input_card.dart - BMI calculation · Converts cm to meters and calculates weight / height².
lib/screens/bmi_calculator_screen.dart - BMI classification · Derives category and category color from BMI.
lib/screens/bmi_calculator_screen.dart - Result card · Renders score, category badge, and animated radial gauge.
lib/widgets/result_card.dart - BMI reference table · Explains category thresholds and colors.
lib/widgets/bmi_reference_table.dart - gauge_indicator · Provides the animated radial gauge.
pubspec.yaml
Android packaging
Native launcher and Gradle packaging boundary.
- Android manifest
android/app/src/main/AndroidManifest.xml - App Gradle build
android/app/build.gradle.kts - MainActivity · Embeds the Flutter runtime.
android/app/src/main/kotlin/com/bmi/calculator/bmi_calculator/MainActivity.kt
Connections 17
- App Gradle build → Android manifest: packages
- Android manifest → MainActivity: launches
- MainActivity → App bootstrap: hosts Flutter
- App bootstrap → App colors: applies theme
- App bootstrap → Splash screen: initial screen
- Splash screen → BMI calculator: replacement navigation
- BMI calculator → Input card: renders fields
- Input card → BMI calculator: validated input
- BMI calculator → BMI calculation: submits values
- BMI calculation → BMI classification: BMI value
- BMI classification → BMI calculator: category state
- BMI calculator → Result card: calculated result
- BMI calculator → BMI reference table: renders legend
- App colors → BMI classification: category colors
- App colors → Result card: visual semantics
- App colors → BMI reference table: legend colors
- gauge_indicator → Result card: animated gauge