library_annotations
This annotation should be attached to a library directive.
Description
#The analyzer produces this diagnostic when an annotation that applies to a whole library isn't associated with a library
directive.
Example
#The following code produces this diagnostic because the TestOn
annotation, which applies to the whole library, is associated with an import
directive rather than a library
directive:
dart
@TestOn('browser')
import 'package:test/test.dart';
void main() {}
Common fixes
#Associate the annotation with a library
directive, adding one if necessary:
dart
@TestOn('browser')
library;
import 'package:test/test.dart';
void main() {}
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.