How adityaambre/cricket_stats works
Project Type and Purpose
• This is a single-page mobile application built in Flutter, targeting Android and iOS, that fetches and displays cricket statistics.
• It follows an MVVM-style layering: presentation (screens + view-models), data (API + models), plus shared utilities and resources.
File Structure
• Native host code under android/ and ios/—these folders contain platform-specific build/configuration, the Flutter engine embedding, and app delegates/manifests.
• Dart code under lib/ subdivided into:
• core/ for API client setup (api.dart)
• model/ for data structures (cricket_model.dart)
• screen/ for each UI feature (splash, match, team), each with view.dart, view_model.dart, and platform-specific mobile variants
• widget/ for reusable UI components (e.g., dialog.dart)
• util/ for logging and helper functions
• Entry point: lib/main.dart.
README for Insights
• Confirms Flutter SDK 3.24.3 and Dart 3.5.3
• No backend code; the app relies on external cricket-stats REST APIs via core/api.dart.
a. Native Shells
• Android (Gradle projects, manifest, MainActivity.java)
• iOS (Xcode workspace, AppDelegate.swift)
b. Flutter Engine & Dart VM
• Bridges native and Dart code
c. Presentation Layer (MVVM)
• Screens: SplashScreen, MatchView, TeamView
• ViewModels: manage state, call API client
• Widgets: Dialogs, common UI elements
d. Domain/Data Layer
• API Client (core/api.dart): issues HTTP requests to external cricket-stats endpoints
• Models (cricket_model.dart): parse JSON into Dart classes
e. Shared Resources
• Constants (constant/constant.dart)
• Utilities (util/logger.dart, util/util.dart)
f. External Services
• Cricket Stats REST API (third-party or internal)
Relationships and Interactions
• User taps a UI widget → Screen widget triggers ViewModel action → ViewModel calls API client → HTTP request to external service → JSON response → Model parsed → ViewModel updates state → UI rebuilds via Flutter’s reactive framework.
• Constants and resources are accessed across all layers. Utilities support logging and common helper functions.
Architectural Patterns & Principles
• MVVM: clear separation of Views (UI), ViewModels (state + logic), and Models (data).
• Layered architecture: Presentation → Domain/Data → External.
• Dependency inversion: ViewModels depend on abstracted API client interfaces.