# Production-Ready Flutter Mobile Application Rules ## 1. Core Development Philosophy Build the application as a production-ready mobile product, not as a prototype or demo. The primary goals are: 1. Stability 2. Security 3. Maintainability 4. Scalability 5. Performance 6. Accessibility 7. Excellent UX 8. Testability 9. Reliable networking 10. Production deployment readiness Never sacrifice application stability just to implement a feature faster. Before modifying existing code: - Inspect the existing architecture. - Inspect the affected feature. - Inspect related models. - Inspect API contracts. - Inspect state management. - Inspect navigation. - Inspect authentication requirements. - Inspect existing tests. - Identify dependencies and side effects. Do not blindly rewrite entire files. Do not remove working functionality unless explicitly requested. Do not replace a working architecture with another architecture without a clear technical reason. --- # 2. Technology Stack Preferred stack: - Flutter - Dart - Android - iOS - Material 3 where appropriate - Cupertino components where platform-specific behavior is beneficial - REST/JSON APIs - Repository Pattern - MVVM - Dependency Injection - Immutable data models - Async/await - Streams where appropriate - Automated testing Prefer official Flutter and platform APIs before introducing unnecessary third-party packages. Every dependency must have a clear purpose. Avoid adding packages for functionality that can be implemented safely with the Flutter SDK. --- # 3. Architecture Use a layered architecture. Minimum architecture: ```text Presentation ↓ Domain / Business Logic ↓ Data ↓ Remote / Local Services UI ↓ ViewModel ↓ UseCase ↓ Repository ↓ DataSource ↓ API / Local Database lib/ │ ├── app/ │ ├── app.dart │ ├── router/ │ ├── theme/ │ └── config/ │ ├── core/ │ ├── constants/ │ ├── errors/ │ ├── extensions/ │ ├── network/ │ ├── storage/ │ ├── security/ │ ├── utils/ │ └── widgets/ │ ├── features/ │ │ ├── authentication/ │ │ ├── data/ │ │ ├── domain/ │ │ └── presentation/ │ │ │ ├── home/ │ │ ├── data/ │ │ ├── domain/ │ │ └── presentation/ │ │ │ ├── profile/ │ │ ├── data/ │ │ ├── domain/ │ │ └── presentation/ │ │ │ └── settings/ │ ├── data/ │ ├── domain/ │ └── presentation/ │ └── main.dart HomeView ↓ HomeViewModel ↓ HomeRepository ↓ HomeApiService ApiClient ↓ AuthApiService UserApiService ProductApiService NotificationApiService finally App ↓ Create payment request ↓ Server validates product ↓ Payment provider ↓ Server verifies payment ↓ Server grants product ↓ App refreshes account