Metadata
Use metadata to give additional information about your code. A metadataannotation begins with the character @, followed by either a referenceto a compile-time constant (such as deprecated) or a call to aconstant constructor.
Two annotations are available to all Dart code: @deprecated and@override. For examples of using @override,see Extending a class.Here’s an example of using the @deprecatedannotation:
1. class Television {
2. /// _Deprecated: Use [turnOn] instead._
3. @deprecated
4. void activate() {
5. turnOn();
6. }
8. /// Turns the TV's power on.
9. void turnOn() {...}
10. }
You can define your own metadata annotations. Here’s an example ofdefining a @todo annotation that takes two arguments:
1. library todo;
3. class Todo {
4. final String who;
5. final String what;
7. const Todo(this.who, this.what);
8. }
And here’s an example of using that @todo annotation:
1. import 'todo.dart';
3. @Todo('seth', 'make this do something')
4. void doSomething() {
5. print('do something');
6. }
Metadata can appear before a library, class, typedef, type parameter,constructor, factory, function, field, parameter, or variabledeclaration and before an import or export directive. You canretrieve metadata at runtime using reflection.
