How stevenosse/flutter_kit works
Project Type and Purpose
• This is an opinionated, feature-first Flutter starter kit for building cross-platform (iOS/Android) mobile apps.
• It provides a preconfigured architecture covering UI, state management, routing, theming, internationalization, HTTP data sources, code generation, and basic utilities.
File Structure Analysis
• Top-level:
• android/ & ios/ – native project wrappers
• lib/ – application code
• assets/ – fonts and images
• test/ – widget/unit test stubs
• lib/src/:
• core/ – app initialization, environment config, i18n, routing, theming
• datasource/ – HTTP client setup (Dio), API models, repositories
• features/ – feature-scoped folders (e.g., login: UI + logic)
• shared/ – reusable widgets, extensions, service locator, storage/logger services
• Codegen: build_runner + flutter_gen for assets and intl_utils for translations.
• Build & CI: Makefile, GitHub Actions (static analysis).
Key Architectural Patterns
• Layered architecture (Presentation → Domain/Logic → Data)
• Feature-first folder structure
• Repository pattern for data access
• ChangeNotifier-based state management (controllers)
• Dependency injection via a service locator
• Auto_route for declarative navigation
• Material 3 theming and intl_utils for i18n
Main Components
A. Platform Layer
• Android & iOS native shells
• Flutter engine / Dart VM
B. Core Application
• main.dart → AppInitializer → Application widget
• Environment config
• Routing (AppRouter)
• i18n (intl generated code, ARB files)
C. Presentation Layer
• Screens (e.g., LoginScreen)
• Widgets & shared components (atoms, buttons, dialogs)
• Navigation actions (router.push/pop)
D. Business Logic Layer
• Controllers (ChangeNotifier classes)
• State classes
• ViewModel-style binding between UI and controllers
E. Data Layer
• Repositories (e.g., ExampleRepository)
• API models (ApiResponse)
• HTTP client utilities (DioConfig, HttpUtil)
F. Services & Utilities
• Storage services (local/in-memory)
• Logging service
• ServiceLocator registration
G. Code Generation & Build Tools (side note)
• flutter_gen (assets.gen.dart)
• intl_utils (messages_all.dart)
H. External Dependencies
• Remote API endpoints
• Pub.dev packages: auto_route, dio, intl_utils, flutter_gen
Relationships and Data Flow
1. App starts → main.dart calls AppInitializer → registers services in ServiceLocator
2. Application builds → injects AppRouter, Theme, Localization delegates
3. User navigates to a Feature Screen → Router instantiates Screen widget
4. UI widget obtains its Controller from ServiceLocator or Provider
5. Controller invokes Repository methods → uses HttpUtil/Dio to make network calls → parses ApiResponse → returns domain models
6. Controller updates its state → UI listens to ChangeNotifier → rebuilds widgets
7. Services like LocalStorage can be used by Repositories or Controllers for caching/ persistence
8. Shared components and extensions are leveraged by multiple features