flutter-dev
它能做什么
这项技能是使用 Flutter 和 Dart 构建跨平台应用的指南。适合希望在页面、状态、导航和性能方面掌握成熟模式的开发者。
适用场景
- ✓当你为手机或其他平台构建 Flutter 应用的时候。
- ✓当你需要选择 Riverpod 或 Bloc 等状态管理方式的时候。
- ✓当你的 Flutter 应用运行缓慢,你想提升其性能的时候。
技能链接
https://github.com/MiniMax-AI/skills/blob/main/skills/flutter-dev/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我构建一个 Flutter 购物应用,包含页面导航和加载迅速的商品列表。”
每周 5 个新技能,1 分钟读完。
工作原理
这项技能提供了组件和性能模式的表格,以及核心规则,例如使用 const 构造函数。智能体会把这些模式应用到你描述的页面和功能中。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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
constconstructors wherever possible - Extract static widgets to separate const classes
- Use
Keyfor list items (ValueKey, ObjectKey) - Prefer
ConsumerWidgetoverStatefulWidgetfor 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
RepaintBoundaryfor complex animations - Offload heavy work with
compute()
Checklist
Widget Best Practices
-
constconstructors on all static widgets - Proper
Keyon list items -
ConsumerWidgetfor state-dependent widgets - No widget building inside
build()method - Extract reusable widgets to separate files
State Management
- Immutable state objects
-
select()for granular rebuilds - Proper provider scoping
- Dispose controllers and subscriptions
- Handle loading/error states
Navigation
- GoRouter with typed routes
- Auth guards via redirect
- Deep linking support
- State preservation across routes
Performance
- Profile mode testing (
flutter run --profile) - <16ms frame rendering time
- No unnecessary rebuilds (DevTools check)
- Images cached and resized
- Heavy computation in isolates
Testing
- Widget tests for UI components
- Unit tests for business logic
- Integration tests for user flows
- Bloc tests with
blocTest()
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.
常见问题
它如何帮助提升速度?
它推荐使用 const 构造函数、选择性更新和惰性列表等模式,以避免不必要的重新构建。
它使用哪种导航?
它使用 GoRouter 在页面之间切换。
它涵盖测试吗?
涵盖。这项技能包含测试策略和 DevTools 性能分析。
详情
作者的原始描述
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.
repo: MiniMax-AI/skills
热度
- GitHub 星标
- 14k
- 排名
- #11288
- 许可证
- MIT
- 更新时间
- 2026/4/18
评论
- …
同一仓库的更多技能
design-style-skill
14k帮你的智能体为幻灯片选定一种统一的视觉风格,从锐利紧凑到柔和、圆润或宽松,并配以相应的圆角和间距。
ppt-editing-skill
14k帮你的智能体安全地编辑现有的 PowerPoint 文件或模板,包括修改文字、调整或删除幻灯片,并重新打包成有效的演示文稿。
ppt-orchestra-skill
14k帮你的智能体在制作之前规划整套 PowerPoint 演示文稿,把每张幻灯片归入标准页面类型,并检查版式多样性和文字质量。
slide-making-skill
14k帮你的智能体用 JavaScript 和 PptxGenJS 编写单张 PowerPoint 幻灯片,涵盖版式、文字、图片、图表和字体,生成原生 .pptx 文件。