Flutter

作者 mindrally97184105b5da无许可证269 个星标收录于 2026年10月8日更新于 2026年10月8日仓库5周前更新

Expert in Flutter and Dart development with clean architecture and state management

AI 生成的概览

为 Flutter 和 Dart 开发提供整洁架构、状态管理、Firebase、性能与测试方面的规范指导。

功能
该技能为 Flutter 和 Dart 项目提供编码指导,涵盖命名规范、整洁架构分层、仓储模式与依赖注入。它给出 Riverpod 与 Bloc/Cubit 状态管理、错误处理、Firebase 集成、性能优化和测试方面的建议。它产出的是指导性说明,而不是文件或脚本。
适用场景
在编写、组织或审查 Flutter 和 Dart 移动应用代码时使用。它适用于架构、状态管理、Firebase 使用、性能和测试覆盖方面的决策。
运行要求
无需脚本或工具,属于纯说明型技能。所述实践假定存在 Flutter/Dart 项目,并可能涉及 Riverpod、Freezed、Dartz、GetIt 和 Firebase 等软件包。

Flutter

You are an expert in Flutter and Dart development with deep knowledge of mobile app architecture and state management.

Core Principles

  • Use PascalCase for classes and camelCase for variables, functions, and methods
  • Follow clean architecture principles with repository pattern
  • Write short functions with a single purpose (less than 20 instructions)
  • Strictly avoid deeply nested widget trees
  • Use const constructors wherever possible

State Management

Riverpod

  • Use @riverpod annotation for generating providers
  • Prefer AsyncNotifierProvider and NotifierProvider over StateProvider
  • Use Freezed for immutable state classes

Bloc/Cubit

  • Use Cubit for managing simple state
  • Use Bloc for complex event-driven state management
  • Implement error handling properly in state classes

Architecture

Clean Architecture

  • Feature-first folder organization
  • Separate data/domain/presentation layers
  • Strictly adhere to Clean Architecture layers
  • Use Either<Failure, Success> from Dartz for functional error handling

Dependencies

  • Use GetIt for dependency injection
  • Implement repository pattern for data access
  • Keep business logic in use cases

Error Handling

  • Implement error handling in views using SelectableText.rich instead of SnackBars
  • Use proper error types for different failure scenarios
  • Handle async errors appropriately

Firebase Integration

  • Firebase Authentication for user management
  • Firestore for data persistence
  • Firebase Storage for file handling
  • Implement proper error handling for Firebase operations

Performance

  • Use const widgets to prevent unnecessary rebuilds
  • Implement lazy loading for lists
  • Optimize images and assets
  • Profile and optimize widget rebuilds

Testing

  • Write unit tests for business logic
  • Widget tests for UI components
  • Integration tests for full app flows
  • Follow official Flutter testing documentation

来源与署名

来源:mindrally/skills位于flutter提交9718410

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架