搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案