搜索插件、代码仓与 APP 分类

插件详情v4.2.1

kiwi_generator

使用 kiwi 包生成依赖注入代码,以减少开发时间。

macOSWindowsLinux
近 30 天下载
2880
喜欢数
13
Pub 分数
150

安装插件

flutter pub add kiwi_generator

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Kiwi Generator 是一个代码生成工具,通过 Kiwi 包自动设置依赖注入,显著减少样板代码和开发时间。它基于注解生成干净、类型安全的注入代码,从而在 Flutter 应用中高效管理依赖项。通过利用构建时代码生成,确保性能并降低运行时开销。该生成器与 Kiwi DI 框架无缝集成,并支持跨平台开发,涵盖 macOS、Windows 和 Linux。非常适合希望简化依赖管理而无需手动配置的开发者。

适合场景

  • 自动化依赖注入设置
  • 减少大型应用中的样板代码
  • 简化可测试的架构
  • 启用类型安全注入
  • 支持可扩展的应用程序结构

主要特点

  • 构建时代码生成
  • 基于注解的配置
  • 类型安全的依赖项解析
  • 与 Kiwi 的无缝集成
  • 跨平台支持

适合对象

  • 大规模 Flutter 项目
  • 注重可维护性的团队
  • 使用依赖注入的开发者
  • 需要可测试架构的应用程序
  • 旨在减少手动设置的项目

使用建议

  • 需要理解 Kiwi DI 原则
  • 需要 build_runner 进行代码生成
  • 可能会增加初始构建时间
  • 与手动依赖注入相比,自定义选项有限
  • 取决于 Kiwi 包版本兼容性

原始 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.

所属分类

依赖

依赖清单 9 项

源码仓库

使用此插件的项目