Sorry for the anwser, but actually, it's not possible to do what you want.
For a simple reason : Your code is syntaxicly correct, but no instance of the annotation is created.
example :
class Testing {
Testing(String toPrint) {
print(toPrint);
}
}
class annotation {
final Testing test;
const annotation(this.test);
}
void main() {
@annotation(new Testing("Annotation instanciation")) var a = "hello";
print(a);
var annot = new annotation(new Testing("Local instanciation"));
print(a);
}
This code result :
$ hello
$ Local instanciation
$ hello
So the annotation constructor has never been called.
May be this features will be add in the future
Information :
Actually, it doesn't work in this case because it's a local variable declaration. for a function, class or others, it will work.