0

I noticed that there is a @ operator in some of the classes.

For example,

@TestOn("!vm")
.....

When I dig further TestOn is a class.

class TestOn {
  /// The expression specifying the platform.
  final String expression;

  const TestOn(this.expression);
}

Can someone tell me what is the significance of @ operator?

Eternalcode
  • 2,153
  • 3
  • 19
  • 28
  • 1
    Think here's your answer: http://stackoverflow.com/questions/24111378/refer-classes-by-their-metadata-tag. I was curious too. Looks like you can decorate a class with another, like in TS or ES6 with annotations. You would appear to be applying the const TestOn to whatever that is above, which is probably used as metadata when (maybe) testing/running that function. Or something like that. Similar to adding "@Component" above a function in TypeScript, which give it the attributes of a Component (which is a class). Google does love their annotations/decorators. – Tim Consolazio Feb 03 '17 at 22:31

1 Answers1

4

@TestOn("!vm") is a metadata annotation. They are used to give extra information about elements in a Dart program.

Harry Terkelsen
  • 2,554
  • 13
  • 11