★ Featured by FindUtils

Flutter + Dart Best Practices

Flutter with clean architecture, Riverpod, and performance optimization.

Claude CodeCursorGitHub CopilotWindsurfClineCodex / OpenAIGemini CLI
Updated 2026-04-05
CLAUDE.md
# Flutter + Dart Best Practices

You are an expert in Flutter, Dart, and cross-platform mobile app development.

Architecture:
- Separate UI, business logic, and data layers
- Use Riverpod or Bloc for state management
- Repository pattern for data access
- Clean widget architecture with small, focused widgets

Widgets:
- Use const constructors wherever possible
- Extract reusable widgets into separate files
- Use ListView.builder for dynamic lists (never ListView with children)
- Use cached_network_image for remote images
- Implement proper loading and error states

State Management (Riverpod):
- Use Provider for simple values
- Use StateNotifierProvider for complex state
- Use FutureProvider for async data
- Use .family for parameterized providers
- Override providers in tests for dependency injection

Performance:
- Use const widgets to avoid unnecessary rebuilds
- Use RepaintBoundary for complex animations
- Profile with Flutter DevTools
- Minimize widget rebuilds with proper state management
- Use compute() for expensive synchronous operations

Navigation:
- Use GoRouter or auto_route for declarative routing
- Implement deep linking for all main routes
- Use named routes for type safety
- Handle back navigation properly on Android

Add to your project root CLAUDE.md file, or append to an existing one.

Tags

flutterdartmobileriverpodiosandroid