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. Includes4 const optimization, responsive layouts, testing strategies, and DevTools profiling.56 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.78 '9description_zh: Flutter 跨平台开发指南10description_en: Flutter cross-platform dev guide (Riverpod, GoRouter)11version: 1.0.012metadata:13 source: https://skillmd.com/skills/infometa/flutter-dev14 version: 1.0.015 category: mobile16 sources:17 - Flutter Documentation18 - Riverpod Documentation19 - Bloc Library Documentation20license: MIT21---2223# Flutter Development Guide2425A practical guide for building cross-platform applications with Flutter 3 and Dart. Focuses on proven patterns, state management, and performance optimization.2627## Quick Reference2829### Widget Patterns3031| Purpose | Component |32|---------|-----------|33| State management (simple) | `StateProvider` + `ConsumerWidget` |34| State management (complex) | `NotifierProvider` / `Bloc` |35| Async data | `FutureProvider` / `AsyncNotifierProvider` |36| Real-time streams | `StreamProvider` |37| Navigation | `GoRouter` + `context.go/push` |38| Responsive layout | `LayoutBuilder` + breakpoints |39| List display | `ListView.builder` |40| Complex scrolling | `CustomScrollView` + Slivers |41| Hooks | `HookWidget` + `useState/useEffect` |42| Forms | `Form` + `TextFormField` + validation |4344### Performance Patterns4546| Purpose | Solution |47|---------|----------|48| Prevent rebuilds | `const` constructors |49| Selective updates | `ref.watch(provider.select(...))` |50| Isolate repaints | `RepaintBoundary` |51| Lazy lists | `ListView.builder` |52| Heavy computation | `compute()` isolate |53| Image caching | `cached_network_image` |5455## Core Principles5657### Widget Optimization58- Use `const` constructors wherever possible59- Extract static widgets to separate const classes60- Use `Key` for list items (ValueKey, ObjectKey)61- Prefer `ConsumerWidget` over `StatefulWidget` for state6263### State Management64- Riverpod for dependency injection and simple state65- Bloc/Cubit for event-driven workflows and complex logic66- Never mutate state directly (create new instances)67- Use `select()` to minimize rebuilds6869### Layout70- 8pt spacing increments (8, 16, 24, 32, 48)71- Responsive breakpoints: mobile (<650), tablet (650-1100), desktop (>1100)72- Support all screen sizes with flexible layouts73- Follow Material 3 / Cupertino design guidelines7475### Performance76- Profile with DevTools before optimizing77- Target <16ms frame time for 60fps78- Use `RepaintBoundary` for complex animations79- Offload heavy work with `compute()`8081## Checklist8283### Widget Best Practices84- [ ] `const` constructors on all static widgets85- [ ] Proper `Key` on list items86- [ ] `ConsumerWidget` for state-dependent widgets87- [ ] No widget building inside `build()` method88- [ ] Extract reusable widgets to separate files8990### State Management91- [ ] Immutable state objects92- [ ] `select()` for granular rebuilds93- [ ] Proper provider scoping94- [ ] Dispose controllers and subscriptions95- [ ] Handle loading/error states9697### Navigation98- [ ] GoRouter with typed routes99- [ ] Auth guards via redirect100- [ ] Deep linking support101- [ ] State preservation across routes102103### Performance104- [ ] Profile mode testing (`flutter run --profile`)105- [ ] <16ms frame rendering time106- [ ] No unnecessary rebuilds (DevTools check)107- [ ] Images cached and resized108- [ ] Heavy computation in isolates109110### Testing111- [ ] Widget tests for UI components112- [ ] Unit tests for business logic113- [ ] Integration tests for user flows114- [ ] Bloc tests with `blocTest()`115116## References117118| Topic | Reference |119|-------|-----------|120| Widget patterns, const optimization, responsive layout | [Widget Patterns](references/widget-patterns.md) |121| Riverpod providers, notifiers, async state | [Riverpod State Management](references/riverpod-state.md) |122| Bloc, Cubit, event-driven state | [Bloc State Management](references/bloc-state.md) |123| GoRouter setup, routes, deep linking | [GoRouter Navigation](references/gorouter-navigation.md) |124| Feature-based structure, dependencies | [Project Structure](references/project-structure.md) |125| Profiling, const optimization, DevTools | [Performance Optimization](references/performance.md) |126| Widget tests, integration tests, mocking | [Testing Strategies](references/testing.md) |127| iOS/Android/Web specific implementations | [Platform Integration](references/platform-specific.md) |128| Implicit/explicit animations, Hero, transitions | [Animations](references/animations.md) |129| Dio, interceptors, error handling, caching | [Networking](references/networking.md) |130| Form validation, FormField, input formatters | [Forms](references/forms.md) |131| i18n, flutter_localizations, intl | [Localization](references/localization.md) |132133---134135Flutter, 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.