no_annotation_constructor_arguments
Annotation creation must have arguments.
Description
#The analyzer produces this diagnostic when an annotation consists of a single identifier, but that identifier is the name of a class rather than a variable. To create an instance of the class, the identifier must be followed by an argument list.
Example
#The following code produces this diagnostic because C
is a class, and a class can't be used as an annotation without invoking a const
constructor from the class:
dart
class C {
const C();
}
@C
var x;
Common fixes
#Add the missing argument list:
dart
class C {
const C();
}
@C()
var x;
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.