跳到正文
Skillpedia
移动应用14k · #11288

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/MiniMax-AI/skills/blob/main/skills/flutter-dev/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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 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

  • const constructors on all static widgets
  • Proper Key on list items
  • ConsumerWidget for 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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能