如何在Dart中获取注释元数据? [英] How to get Annotation metadata in Dart?

查看:237
本文介绍了如何在Dart中获取注释元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 package:analyzer 软件包。我扩展了 SimpleElementVisitor 来访问该类的所有字段。 visitFieldElement(FieldElement element)提供所有字段的数据类型和字段名称。但是某些字段使用自定义注释进行注释。我如何读取该注释的元数据?

I am using package:analyzer package. I have extended SimpleElementVisitor to visit all the fields of the class. visitFieldElement(FieldElement element) is providing all the fields data type and fields name. But some of the fields are annotated with custom annotation. How I can read the metadata of that annotation?

推荐答案

元素实例(示例中为 FieldElement ),您可以使用 元数据字段以读取注释。

From the Element instance (A FieldElement in the example) you can use the metadata field to read out annotations.

这篇关于如何在Dart中获取注释元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆