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

插件详情v5.2.3

reflectable

基于代码生成的反射支持,使用'capabilities'指定要在哪些对象上支持哪些操作。这是 reflectable 的运行时部分。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1.7万
喜欢数
188
Pub 分数
160

安装插件

flutter pub add reflectable

插件介绍

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

Reflectable 通过代码生成在 Dart 中提供反射功能,支持对类型、字段、方法和构造函数的运行时检查和操作。它不依赖于内置的反射(在 Flutter 中功能有限),而是使用“功能”来定义特定类支持哪些反射操作。这种方法确保了在 Android、iOS、Web、macOS、Windows 和 Linux 等平台上的性能和兼容性。它非常适合需要动态行为但又不牺牲树摇或性能的框架和库。

适合场景

  • 动态序列化/反序列化
  • 运行时类型检查
  • 通用框架开发
  • API 的代码生成
  • 插件和库的可扩展性

主要特点

  • 代码生成的反射
  • 基于能力的操作控制
  • 跨平台支持
  • 最小的运行时开销
  • 与 build_runner 的集成
  • 支持字段、方法和构造函数

适合对象

  • 框架开发者
  • 库作者
  • 需要动态类型处理的工具
  • 使用代码生成的应用程序
  • 对性能敏感的应用程序

使用建议

  • 需要 build_runner 和代码生成
  • 限于显式声明的功能
  • 不适用于仅运行时的反射
  • 需要仔细设置 reflectable 注解
  • 可能会略微增加构建时间

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

This repository provides the Dart packages reflectable and reflectable_builder, along with a set of test cases and examples in the repository test_reflectable.

reflectable

Support for implementing a large subset of the features offered by 'dart:mirrors' without relying on 'dart:mirrors' itself. Provides a system based on capabilities to control the amount of reflection support.

reflectable_builder

Support for generating the code that the package reflectable uses to provide the reflection support described above.

test_reflectable

Used to test package reflectable. Also serves as a set of examples of how reflectable can be used.

所属分类

源码仓库

使用此插件的项目