Javatpoint Logo
Javatpoint Logo

Dart Metadata

The Dart Metadata is used to specify the Dart program with additional information. It usually starts with @ symbol, followed by either a reference of the compile-time constant or a call to a constant constructor.

Creating Metadata Annotation

In Dart, we can define our own metadata annotations.

Let's understand the following example -

Example -

Here's an example of defining a @student annotation that takes two arguments -

And, here is the following example we are using @student annotation.

In Dart, metadata generally define just before a library name, class, typedef, field, type parameter, factory, function, constructor, parameter, or variable declaration and before an import or export directive. We can retrieve the metadata using reflection in runtime.

Let's understand the following example.

Example -


Boy is running

In the above code, we have provided the addition information to the both parent class and child class functions.

Next TopicDart Collection

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA