SKILL

dart-flutter-patterns

Production-ready Dart and Flutter patterns covering null safety, immutable state, async composition, Widget architecture, popular state management frameworks (BLoC, Riverpod, Provider), GoRouter navigation, Dio networking, Freezed code generation, and clean architecture.

Machine translation
Read the original Chinese text

生产就绪的 Dart 和 Flutter 模式,涵盖空安全、不可变状态、异步组合、Widget 架构、流行的状态管理框架(BLoC、Riverpod、Provider)、GoRouter 导航、Dio 网络请求、Freezed 代码生成和整洁架构。

Target: Mobile development. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original Chinese text

Topics in the source

  • Dart/Flutter 模式
  • 使用场景
  • 工作原理
  • 示例
  • 1. 空安全基础
  • 优先使用模式而非感叹号操作符
  • 避免过度使用 late
  • 2. 不可变状态

在以下情况使用此技能: 开始新的 Flutter 功能,需要状态管理、导航或数据访问的惯用模式 审查或编写 Dart 代码,需要空安全、密封类型或异步组合的指导 搭建新的 Flutter 项目,在 BLoC、Riverpod 或 Provider 之间做选择 实现安全的 HTTP 客户端、WebView 集成或本地存储 为 Flutter 组件、Cubit 或 Riverpod 提供者编写测试 使用认证守卫配置 GoRouter 此技能提供按关注点组织的、可直接复制粘贴的 Dart/Flutter 代码模式: 1. 空安全 — 避免 !,优先使用 ?./??/模式匹配 2. 不可变状态 — 密封类、freezed、copyWith 3. 异步组合 — 并发 Future.wait、BuildContext 后安全使用 await 4. 组件架构 — 提取为类(而非方法)、const 传播、作用域重建 5. 状态管理 — BLoC/Cubit 事件、Riverpod 通知器和派生提供者 6. 导航 — 通过 refreshListenable 实现带响应式认证守卫的 GoRouter 7. 网络请求 — 带拦截器的 Dio、带一次性重试守卫的令牌刷新 8. 错误处理 — 全局捕获、ErrorWidget.builder、Crashlytics 集成 9. 测试 — 单元测试(BLoC 测试)、组件测试(ProviderScope 覆盖)、使用假对象而非模拟对象 适用于 Dart 和 Flutter 应用程序的实用、生产就绪模式。尽可能保持库无关性,并明确覆盖最常见的生态系统包。 Effective Dart: 设计 Flutter 性能最佳实践 Riverpod 文档 BLoC 库 GoRouter Freezed 技能:flutter-dart-code-review — 全面审查清单 规则:rules/dart/ — 编码风格、模式、安全性、测试、钩子

Source repository
affaan-m/ECC
Source file
docs/zh-CN/skills/dart-flutter-patterns/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:50.294Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.