Skill
4
Agent
All Skills
Search
Tools
中文
|
EN
Explore
Loading...
Back to Details
flutter
Compare original and translation side by side
🇺🇸
Original
English
🇨🇳
Translation
Chinese
Flutter
Flutter
You are an expert in Flutter and Dart development with deep knowledge of mobile app architecture and state management.
您是Flutter和Dart开发专家,精通移动应用架构与状态管理。
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
类使用PascalCase命名,变量、函数和方法使用camelCase命名
遵循整洁架构原则,采用仓库模式
编写单一职责的短函数(少于20条指令)
严格避免深度嵌套的Widget树
尽可能使用const构造函数
State Management
状态管理
Riverpod
Riverpod
Use @riverpod annotation for generating providers
Prefer AsyncNotifierProvider and NotifierProvider over StateProvider
Use Freezed for immutable state classes
使用@riverpod注解生成提供者
优先使用AsyncNotifierProvider和NotifierProvider,而非StateProvider
使用Freezed创建不可变状态类
Bloc/Cubit
Bloc/Cubit
Use Cubit for managing simple state
Use Bloc for complex event-driven state management
Implement error handling properly in state classes
使用Cubit管理简单状态
使用Bloc处理复杂的事件驱动型状态管理
在状态类中正确实现错误处理
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
以功能为优先的文件夹组织方式
分离数据/领域/表现层
严格遵循整洁架构分层
使用Dartz库中的Either<Failure, Success>进行函数式错误处理
Dependencies
依赖管理
Use GetIt for dependency injection
Implement repository pattern for data access
Keep business logic in use cases
使用GetIt进行依赖注入
为数据访问实现仓库模式
将业务逻辑存放在用例中
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
在视图中使用SelectableText.rich替代SnackBars实现错误处理
针对不同失败场景使用合适的错误类型
妥善处理异步错误
Firebase Integration
Firebase集成
Firebase Authentication for user management
Firestore for data persistence
Firebase Storage for file handling
Implement proper error handling for Firebase operations
使用Firebase Authentication进行用户管理
使用Firestore进行数据持久化
使用Firebase Storage处理文件
为Firebase操作实现完善的错误处理
Performance
性能优化
Use const widgets to prevent unnecessary rebuilds
Implement lazy loading for lists
Optimize images and assets
Profile and optimize widget rebuilds
使用const Widget避免不必要的重建
为列表实现懒加载
优化图片与资源
分析并优化Widget重建
Testing
测试
Write unit tests for business logic
Widget tests for UI components
Integration tests for full app flows
Follow official Flutter testing documentation
为业务逻辑编写单元测试
为UI组件编写Widget测试
为完整应用流程编写集成测试
遵循官方Flutter测试文档