Dart Metadata

In this tutorial you will learn about the Dart Metadata and its application with practical example.

Dart Metadata

In Dart, metadata is used to provide additional information about your dart program. A metadata annotation usually begins with @ character, followed by either a reference to a compile-time constant or a call to a constant constructor.

Note:- The @deprecated and @override are available for all Dart Program.

Creating Metadata Annotations

In Dart, you are allowed to define your own metadata annotations.

Example:-

Here’s an example of defining a @employee annotation that takes two arguments –

And here’s an example of using that @employee annotation –

In Dart, metadata usually appear before a library, class, typedef, type parameter, constructor, factory, function, field, parameter, or variable declaration and before an import or export directive. Metadata can be retrieved using reflection in runtime.

Recommended:-  Dart Boolean
In this tutorial we have learn about the Dart Metadata and its application with practical example. I hope you will like this tutorial.