Flutter Development Guide
A practical guide for building cross-platform applications with Flutter 3 and Dart. Focuses on proven patterns, state management, and performance optimization.
Quick Reference
Widget Patterns
| Purpose |
Component |
| State management (simple) |
StateProvider + ConsumerWidget |
| State management (complex) |
NotifierProvider / Bloc |
| Async data |
FutureProvider / AsyncNotifierProvider |
| Real-time streams |
StreamProvider |
| Navigation |
GoRouter + context.go/push |
| Responsive layout |
LayoutBuilder + breakpoints |
| List display |
ListView.builder |
| Complex scrolling |
CustomScrollView + Slivers |
| Hooks |
HookWidget + useState/useEffect |
| Forms |
Form + TextFormField + validation |
Performance Patterns
| Purpose |
Solution |
| Prevent rebuilds |
const constructors |
| Selective updates |
ref.watch(provider.select(...)) |
| Isolate repaints |
RepaintBoundary |
| Lazy lists |
ListView.builder |
| Heavy computation |
compute() isolate |
| Image caching |
cached_network_image |
Core Principles
Widget Optimization
- Use
const constructors wherever possible
- Extract static widgets to separate const classes
- Use
Key for list items (ValueKey, ObjectKey)
- Prefer
ConsumerWidget over StatefulWidget for state
State Management
- Riverpod for dependency injection and simple state
- Bloc/Cubit for event-driven workflows and complex logic
- Never mutate state directly (create new instances)
- Use
select() to minimize rebuilds
Layout
- 8pt spacing increments (8, 16, 24, 32, 48)
- Responsive breakpoints: mobile (<650), tablet (650-1100), desktop (>1100)
- Support all screen sizes with flexible layouts
- Follow Material 3 / Cupertino design guidelines
Performance
- Profile with DevTools before optimizing
- Target <16ms frame time for 60fps
- Use
RepaintBoundary for complex animations
- Offload heavy work with
compute()
Checklist
Widget Best Practices
State Management
Navigation
Performance
Testing
References
| Topic |
Reference |
| Widget patterns, const optimization, responsive layout |
Widget Patterns |
| Riverpod providers, notifiers, async state |
Riverpod State Management |
| Bloc, Cubit, event-driven state |
Bloc State Management |
| GoRouter setup, routes, deep linking |
GoRouter Navigation |
| Feature-based structure, dependencies |
Project Structure |
| Profiling, const optimization, DevTools |
Performance Optimization |
| Widget tests, integration tests, mocking |
Testing Strategies |
| iOS/Android/Web specific implementations |
Platform Integration |
| Implicit/explicit animations, Hero, transitions |
Animations |
| Dio, interceptors, error handling, caching |
Networking |
| Form validation, FormField, input formatters |
Forms |
| i18n, flutter_localizations, intl |
Localization |
Flutter, Dart, Material Design, and Cupertino are trademarks of Google LLC and Apple Inc. respectively. Riverpod, Bloc, and GoRouter are open-source packages by their respective maintainers.
1---2name: flutter-dev3description: Flutter cross-platform development guide covering widget patterns, Riverpod/Bloc state management, GoRouter navigation, performance optimization, and platform-specific implementations. Includes const optimization, responsive layouts, testing strategies, and DevTools profiling. Use when: building Flutter apps, implementing state management (Riverpod/Bloc), setting up GoRouter navigation, creating custom widgets, optimizing performance, writing widget tests, cross-platform development.4license: MIT5---67# Flutter Development Guide89A practical guide for building cross-platform applications with Flutter 3 and Dart. Focuses on proven patterns, state management, and performance optimization.1011## Quick Reference1213### Widget Patterns1415| Purpose | Component |16|---------|-----------|17| State management (simple) | `StateProvider` + `ConsumerWidget` |18| State management (complex) | `NotifierProvider` / `Bloc` |19| Async data | `FutureProvider` / `AsyncNotifierProvider` |20| Real-time streams | `StreamProvider` |21| Navigation | `GoRouter` + `context.go/push` |22| Responsive layout | `LayoutBuilder` + breakpoints |23| List display | `ListView.builder` |24| Complex scrolling | `CustomScrollView` + Slivers |25| Hooks | `HookWidget` + `useState/useEffect` |26| Forms | `Form` + `TextFormField` + validation |2728### Performance Patterns2930| Purpose | Solution |31|---------|----------|32| Prevent rebuilds | `const` constructors |33| Selective updates | `ref.watch(provider.select(...))` |34| Isolate repaints | `RepaintBoundary` |35| Lazy lists | `ListView.builder` |36| Heavy computation | `compute()` isolate |37| Image caching | `cached_network_image` |3839## Core Principles4041### Widget Optimization42- Use `const` constructors wherever possible43- Extract static widgets to separate const classes44- Use `Key` for list items (ValueKey, ObjectKey)45- Prefer `ConsumerWidget` over `StatefulWidget` for state4647### State Management48- Riverpod for dependency injection and simple state49- Bloc/Cubit for event-driven workflows and complex logic50- Never mutate state directly (create new instances)51- Use `select()` to minimize rebuilds5253### Layout54- 8pt spacing increments (8, 16, 24, 32, 48)55- Responsive breakpoints: mobile (<650), tablet (650-1100), desktop (>1100)56- Support all screen sizes with flexible layouts57- Follow Material 3 / Cupertino design guidelines5859### Performance60- Profile with DevTools before optimizing61- Target <16ms frame time for 60fps62- Use `RepaintBoundary` for complex animations63- Offload heavy work with `compute()`6465## Checklist6667### Widget Best Practices68- [ ] `const` constructors on all static widgets69- [ ] Proper `Key` on list items70- [ ] `ConsumerWidget` for state-dependent widgets71- [ ] No widget building inside `build()` method72- [ ] Extract reusable widgets to separate files7374### State Management75- [ ] Immutable state objects76- [ ] `select()` for granular rebuilds77- [ ] Proper provider scoping78- [ ] Dispose controllers and subscriptions79- [ ] Handle loading/error states8081### Navigation82- [ ] GoRouter with typed routes83- [ ] Auth guards via redirect84- [ ] Deep linking support85- [ ] State preservation across routes8687### Performance88- [ ] Profile mode testing (`flutter run --profile`)89- [ ] <16ms frame rendering time90- [ ] No unnecessary rebuilds (DevTools check)91- [ ] Images cached and resized92- [ ] Heavy computation in isolates9394### Testing95- [ ] Widget tests for UI components96- [ ] Unit tests for business logic97- [ ] Integration tests for user flows98- [ ] Bloc tests with `blocTest()`99100## References101102| Topic | Reference |103|-------|-----------|104| Widget patterns, const optimization, responsive layout | [Widget Patterns](references/widget-patterns.md) |105| Riverpod providers, notifiers, async state | [Riverpod State Management](references/riverpod-state.md) |106| Bloc, Cubit, event-driven state | [Bloc State Management](references/bloc-state.md) |107| GoRouter setup, routes, deep linking | [GoRouter Navigation](references/gorouter-navigation.md) |108| Feature-based structure, dependencies | [Project Structure](references/project-structure.md) |109| Profiling, const optimization, DevTools | [Performance Optimization](references/performance.md) |110| Widget tests, integration tests, mocking | [Testing Strategies](references/testing.md) |111| iOS/Android/Web specific implementations | [Platform Integration](references/platform-specific.md) |112| Implicit/explicit animations, Hero, transitions | [Animations](references/animations.md) |113| Dio, interceptors, error handling, caching | [Networking](references/networking.md) |114| Form validation, FormField, input formatters | [Forms](references/forms.md) |115| i18n, flutter_localizations, intl | [Localization](references/localization.md) |116117---118119Flutter, Dart, Material Design, and Cupertino are trademarks of Google LLC and Apple Inc. respectively. Riverpod, Bloc, and GoRouter are open-source packages by their respective maintainers.