How felipegarces17/homework-flutter-gorouter works
1. Repository type and scope
- This is a Flutter cross-platform client app. The core application logic lives in lib/, while android/, ios/, web/, macos/, windows/, and linux/ are platform shell projects generated by Flutter.
- There is no backend service in this repo; all functionality is local UI/state logic.
2. Top-level architecture
- The app is organized as a small presentation-layer-only application.
- Main boundaries are:
- App bootstrap in lib/main.dart
- Routing/navigation in lib/router.dart
- Feature screens in lib/screens/
- Each calculator lives in its own screen file, keeping feature logic isolated from navigation and startup code.
3. Entry point and app bootstrap
- lib/main.dart is the executable entry point.
- It initializes the Flutter app using MaterialApp.router, which means navigation is delegated to the router configuration rather than imperative route pushing.
- This is the root of the UI tree and the handoff point into the rest of the app.
4. Navigation subsystem
- lib/router.dart defines the app’s GoRouter setup.
- The router provides a declarative route map from the home menu to the three feature screens:
- Home
- Age calculator
- BMI calculator
- Zodiac calculator
- This is the main navigation boundary: screens do not own route registration; they are mounted by the router.
5. Home screen as the navigation hub
- lib/screens/home_screen.dart acts as the menu and launch pad for the app.
- Its main role is to present entry points to the three calculators, likely via buttons or tiles.
- Architecturally, it is the central coordination UI, but it does not contain the calculation logic itself.
6. Age calculator feature
- lib/screens/age_screen.dart is a stateful feature screen centered on date input and computed age output.
- The readme indicates it uses showDatePicker, so the data flow is:
- user selects birth date
- screen stores date in local state
- age is derived and rendered in the UI
- This screen depends on Flutter’s native date picker dialog, which is an important UI/runtime boundary.
7. BMI calculator feature
- lib/screens/bmi_screen.dart implements a form-style calculator using TextEditingController.
- The likely data flow is:
- user enters numeric values such as height and weight
- controllers capture raw input
- the screen computes BMI and updates the displayed result
- This screen is stateful because it manages user input and recomputes results on interaction.
8. Zodiac calculator feature
- lib/screens/zodiac_screen.dart determines a zodiac sign from a birth date.
- Like the age screen, its input is date-driven, but the output is categorical rather than numeric.
- It likely shares the same boundary pattern: local state + date input + derived display result.
9. State management model
- The app uses local widget state rather than a global state library.
- StatefulWidget and setState() are the primary mechanisms for re-rendering UI after user input.
- This keeps each feature self-contained and reduces coupling between screens.
10. Platform integration layer
- The android/, ios/, macos/, windows/, linux/, and web/ folders contain the platform-specific launchers and build definitions.
- These layers do not contain app-specific business logic; they adapt the Flutter runtime to each target platform.
- For architecture diagrams, they can be shown as thin wrappers around the shared Flutter app.
11. Testing boundary
- test/widget_test.dart provides Flutter test coverage at the widget level.
- This implies the app’s testability is focused on UI behavior rather than services or data persistence, which matches the repo’s simple local-logic design.
12. Build/tooling stack
- The project is built with Flutter 3.41.2, Dart 3.11.0, and go_router 17.2.1.
- pubspec.yaml and pubspec.lock define dependencies and package resolution.
- The Android, iOS, desktop, and web folders are managed through standard Flutter build tooling and platform-native project files.
13. Data flow summary
- The app’s flow is straightforward:
- user enters the app through main.dart
- routing sends them to a screen
- the screen captures input locally
- the screen computes a result locally
- the result is rendered back in the same screen
- There is no persistence, API integration, or shared domain layer in this repository.
14. What to emphasize in an architecture diagram
- Show a single shared Flutter application core in lib/.
- Place main.dart at the entry point, router.dart as the navigation hub, and the four screens as feature leaves.
- Surround that with platform shells for Android/iOS/web/desktop.
- Represent the calculators as UI-driven components with local state and direct user input/output loops.
Main entry points: main.dart main.dart · router.dart router.dart · home_screen.dart Home · age_screen.dart Age calc
Components 18
Shared app
Flutter application code and feature screens
- main.dart · Flutter app bootstrap and UI root
lib/main.dart - router.dart · Declarative route map for the app
lib/router.dart - Home · Launch pad to the calculators
lib/screens/home_screen.dart - Age calc · Date picker driven age calculation UI
lib/screens/age_screen.dart - BMI calc · Text input BMI calculation UI
lib/screens/bmi_screen.dart - Zodiac calc · Birth-date driven zodiac lookup UI
lib/screens/zodiac_screen.dart - Local state · StatefulWidget and setState flow within screens
- Date picker · Native date selection boundary used by date-based screens
- Inputs · TextEditingController driven user entry
- Results · Computed age BMI or zodiac output rendered on screen
Platform shells
Generated host projects for each target platform
Tooling
Build, dependency, and test boundaries
- pubspec · Package and version resolution for Flutter and Dart
pubspec.yaml - Widget tests · Widget-level app behavior coverage
test/widget_test.dart
Connections 25
- main.dart → router.dart: boots · App bootstrap hands off navigation to router
- router.dart → Home: routes · Router mounts the home menu
- router.dart → Age calc: routes · Router mounts the age calculator
- router.dart → BMI calc: routes · Router mounts the BMI calculator
- router.dart → Zodiac calc: routes · Router mounts the zodiac calculator
- Home → Age calc: launches · Home screen links to age calculator
- Home → BMI calc: launches · Home screen links to BMI calculator
- Home → Zodiac calc: launches · Home screen links to zodiac calculator
- Age calc → Date picker: uses · Age screen opens date picker for birth date input
- Zodiac calc → Date picker: uses · Zodiac screen opens date picker for birth date input
- BMI calc → Inputs: uses · BMI screen reads numeric inputs through controllers
- Age calc → Local state: updates · Age screen stores selected date and derived value locally
- BMI calc → Local state: updates · BMI screen recalculates from local widget state
- Zodiac calc → Local state: updates · Zodiac screen stores selected date locally
- Local state → Results: renders · State changes drive derived output display
- pubspec → main.dart: supports · Dependencies and SDK settings support the app
- pubspec → router.dart: supports · go_router dependency enables declarative navigation
- Widget tests → main.dart: covers · Widget tests exercise app startup behavior
- Widget tests → Home: covers · Widget tests can validate visible UI state
- Android → main.dart: hosts · Android shell launches the shared Flutter app
- iOS → main.dart: hosts · iOS shell launches the shared Flutter app
- Web → main.dart: hosts · Web shell launches the shared Flutter app
- macOS → main.dart: hosts · macOS shell launches the shared Flutter app
- Windows → main.dart: hosts · Windows shell launches the shared Flutter app
- Linux → main.dart: hosts · Linux shell launches the shared Flutter app