搜尋套件、儲存庫與 APP 分類

套件詳情v5.0.1

kiwi

一個簡單且高效能的 Dart 與 Flutter 依賴注入容器(可與 kiwi_generator 套件搭配使用)。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.3萬
喜歡數
173
Pub 分數
160

安裝套件

flutter pub add kiwi

套件介紹

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

Kiwi 是一個輕量級且高效能的 Dart 與 Flutter 依賴注入(DI)容器,專為簡化應用程式中相依性的管理而設計。它讓開發者能以最少的樣板程式碼註冊與解析相依性,支援透過 kiwi_generator 套件進行手動與程式碼產生的註冊。Kiwi 可無縫整合至所有主要平台——Android、iOS、Web、macOS、Windows 與 Linux——非常適合可擴展、易維護的應用程式。其簡單的 API 透過容易模擬與取代相依性,促進乾淨架構與可測試性。

適用情境

  • 在大型Flutter應用中管理服務依賴
  • 使用模擬依賴項簡化單元測試和小部件測試
  • 透過明確的關注點分離實現模組化應用架構
  • 支援相依性生命週期管理
  • 與狀態管理解決方案(如 Provider 或 Riverpod)整合
  • 促進複雜依賴圖的程式碼生成

主要特色

  • 輕量且快速的依賴注入容器
  • 透過 kiwi_generator 支援程式碼產生
  • 平台無關(適用於所有Flutter支援的平台)
  • 與現有 Flutter 項目輕鬆整合
  • 靈活的依賴生命週期控制
  • 依賴註冊的清爽、易讀語法

適合對象

  • Flutter 開發者尋找簡單的 DI 解決方案
  • 建構大型可維護應用程式的團隊
  • 需要強大測試策略的項目
  • 開發人員使用程式碼生成以提升效能
  • 針對多個平台且具有共享邏輯的應用

使用建議

  • 使用 kiwi_generator 進行代碼生成需要額外設定
  • 如果在小型項目中過度使用,可能會引入開銷
  • 開發人員不熟悉依賴注入模式的學習曲線
  • 與功能齊全的DI框架相比,內建功能有限
  • 最佳搭配其他狀態管理方法使用

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

kiwi

kiwi kiwi_generator dart_kiwi_example flutter_kiwi_example

Logo

A simple yet efficient IoC container for Dart and Flutter, coupled with a powerful generator to allow you to write less code.

The container does not rely on reflection, it's just a Map, so it's fast.

While using the generator, only constructor injection is supported.

Kiwi

Pub

Source Code

The core package providing the IoC container and the annotations which has no dependencies.

Import it into your pubspec dependencies: section.

Kiwi Generator

Pub

Source Code

The package providing the generator.

Import it into your pubspec dev_dependencies: section.

Dart Kiwi Example

Source Code

An example showing how to setup kiwi and kiwi_generator inside a Dart CLI project.

Flutter Kiwi Example

Source Code

An example showing how to setup kiwi and kiwi_generator inside a Flutter project.

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a new feature, please send a pull request.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案