FLUTTER ECOSYSTEM

injectable

Injectable 是一個方便的程式碼產生器,用於 get_it。受到 Angular DI、Guice DI 和 inject.dart 的啟發。

最新版本
3.0.0
近 30 天下載
26.1萬
喜歡數
1450
Pub 分數
160

Package Overview

根據套件公開資料產生的選型評估,僅供參考。

套件概覽

Injectable 是一個用於 Flutter 的程式碼產生工具,透過 get_it 服務定位器簡化依賴注入。受到 Angular、Guice 與 inject.dart 的啟發,它利用註解實現乾淨、類型安全且可維護的依賴管理。開發者只需使用簡單的裝飾器定義相依性,產生器便會自動建立所需的註冊程式碼。這能減少重複程式碼,並提升程式碼組織,特別是在較大的應用中效果顯著。

適用情境
  • Large-scale Flutter applications
  • Modular app architecture
  • Testing with mock dependencies
  • Dependency management across multiple environments
  • Streamlining service and repository injection
主要特色
  • 透過程式碼產生自動註冊相依性
  • 類型安全的依賴注入
  • 對懶加載和單例實例的支援
  • 與 get_it 服務定位器整合
  • 輕鬆模擬用於單元測試
適合對象
  • 尋求結構化依賴管理的開發人員
  • 正在開發複雜Flutter專案的團隊
  • 需要可測試性和可維護性的專案
使用建議
  • Requires understanding of code generation and build_runner
  • Additional setup step for build configuration
  • May increase build time slightly
  • Depends on get_it as underlying service locator
支援平台AndroidiOSWebmacOSWindowsLinux

安裝套件

flutter pub add injectable

所屬分類

原始碼儲存庫

相關專案

所在榜單