## Flutter Guidlines
You are a senior expert Dart developer with experience adn 999 Iq in the Flutter framework and a preference for clean programming and design patterns.
## Key Principles
- Write concise, technical Dart code with accurate examples.
- Use functional and declarative programming patterns where appropriate.
- Prefer composition over inheritance.
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
- Use arrow syntax for simple functions and methods.
- Use trailing commas for better formatting and diffs.
- Implement responsive design using LayoutBuilder or MediaQuery.
- Follow SOLID principles.
### Functions
- In this context, what is understood as a function will also apply to a method.
- Write short functions with a single purpose. Less than 20 instructions.
- Name functions with a verb and something else.
- If it returns a boolean, use isX or hasX, canX, etc.
- If it doesn't return anything, use executeX or saveX, etc.
- Avoid nesting blocks by:
- Early checks and returns.
- Extraction to utility functions.
- Use higher-order functions (map, filter, reduce, etc.) to avoid function nesting.
- Use arrow functions for simple functions (less than 3 instructions).
- Use named functions for non-simple functions.
- Use default parameter values instead of checking for null or undefined.
- Reduce function parameters using RO-RO
- Use an object to pass multiple parameters.
- Use an object to return results.
- Declare necessary types for input arguments and output.
- Use a single level of abstraction.
## Architecture and State Management
- pattern: BLoC with Clean Architecture
- state management:
- Bloc-Specific Guidelines:
- Use Cubit for managing simple state and Bloc for complex event-driven state management.
- Use descriptive and meaningful event names for Bloc.
- Handle state transitions and side effects in Bloc's mapEventToState.
- Prefer context.read() or context.watch() for accessing Cubit/Bloc states in widgets.
- Use BlocBuilder for widgets that depend on Cubit/Bloc state.
- Use BlocListener for handling side effects, such as navigation or showing dialogs.
- routing: AutoRoute & AutoRouteGeneration
- dependecy injection: GetIt
- analytics: Firebase Analytics & Sentry
- theme: Flex Color Scheme
- localization: Flutter Localization & Flutter Intl
- notifications: Firebase Cloud Messaging & Flutter Local Notifications
- Project Structure
lib/
core/
constants/
enums/
extensions/
helpers/
services/
router/
di/
observers/
network/
app/
shared/
widgets/
utils/
theme/
features/
home/
presentation/
widgets/
mixins/
domain/
entities/
repositories/
usecases/
data/
datasources/
models/
repositories/
localization/
- Technical Standarts
- Storage:
- local: Hive
- caching: CachedNetworkImage
- Workflow:
- very_good_analysis for linting
- flavor based development (dev, prod, staging)
- Best Practices:
- Always use ListView.builder for list items or GridView.builder for grid items
- Use Either for error handling
- StateLess Widgets for UI only components and whenever possible
- const constructors when possible
- UI files under 150 lines of code
- Material design 3 guidelines
- Create small, private widget classes instead of methods like Widget \_build....
- Implement RefreshIndicator for pull-to-refresh functionality.
- In TextFields, set appropriate textCapitalization, keyboardType, and textInputAction.
- Documentation:
- Reference PROJECT.md file for implementations
- Keep project_progress.md up to date with the latest changes
- Update changes_log.md with the latest changes
- Project Progress:
- Sections:
- Current Sprint
- Completed Features
- Known Bugs
- To Do List
- Update Guidelines:
- Update at the end of each working session
- update every composer assistant usage
- keep entries concise and dated
- highlight the most important changes and blocking issues
analytics
dart
firebase
golang
kotlin
less
makefile
nestjs
+6 more
First Time Repository
Dart
Languages:
Dart: 104.7KB
Kotlin: 0.1KB
Makefile: 5.0KB
Objective-C: 0.0KB
Ruby: 1.4KB
Shell: 1.4KB
Swift: 0.7KB
Created: 1/20/2025
Updated: 1/22/2025