Skip to content

How to access metadata of Named Fields in a RecordType using Dart Analyzer? #59817

Open
@jodinathan

Description

@jodinathan

I asked at SO before coming here.

I am working on a Dart builder and need to inspect the metadata (annotations) applied to the named fields of a RecordType. However, while I can successfully access RecordType.namedFields, the resulting RecordTypeNamedField objects do not appear to expose any metadata-related members.

Here is an example of the code I am trying to analyze:

Future<({@SomeAnnotation() String foo, int bar})?> someFunction() async {
  return null;
}

In this case, I need to determine programmatically that the foo field is annotated with @SomeAnnotation.

My Setup:
Dart SDK: 3.6.0
Analyzer version: 6.11.0

Question:
How can I access the metadata (annotations) of a named field in a RecordType using Dart's analyzer package in the context of a builder? Is there a specific API or workaround to achieve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onanalyzer-apiIssues that impact the public API of the analyzer packagearea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.type-questionA question about expected behavior or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions