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 從公開儲存庫中收錄這些內容。

檢舉或申請下架