misspelled_pragma
Reports a pragma whose name is nearly, but not quite, one the SDK and Flutter tools know. Correct the spelling.
- Tier
- blocking
- Scope
- Dart
- Lowest preset
- recommended
- Fix
- none
What it reports
Section titled “What it reports”A pragma of dart:core whose name, given as one string literal, is not a name the SDK and Flutter tools know, but is close to one:
- the same but for the case of its letters, or a
_for a-:vm:entry_point; - or one letter added, dropped or changed (two in a name of twelve characters or more):
vm:prefer-inlne,dart2js:noInlnie.
Both an annotation and a constant made with pragma(...) are judged. The violation is on the name, and the message names the pragma it is close to.
It does not report:
- a known name;
- a name close to none of them, such as one a later toolchain brings or a tool of your own (
my_tool:keep); - a name given as a constant or as adjacent strings;
- a class of the project named
pragma.
A compiler ignores a pragma it does not know, and says nothing. A misspelled vm:entry-point lets the ahead-of-time compiler drop what native code calls into, which then fails at run time. A misspelled inlining pragma asks for nothing.
The known names are the ones the SDK’s and Flutter’s own libraries use. A name is reported only when it is that close to one of them, so a new pragma of a later release is not reported unless it is a near miss of an old one.
Example
Section titled “Example”@pragma('vm:entry_point')void onNativeEvent() {}@pragma('vm:entry-point')void onNativeEvent() {}Rule parameters
Section titled “Rule parameters”Set under the assay: key of the project’s root analysis_options.yaml.
| Rule parameter | Default | Effect |
|---|---|---|
enabled |
true |
false switches the rule off for the whole project. |
exclude |
[] |
Path globs where the rule is silent. |
Suppressing it
Section titled “Suppressing it”Write why on the line directly above the suppression:
// Why it stays as written here.// ignore: misspelled_pragma// ignore_for_file: assay/misspelled_pragma silences it in a whole file, and the prefixed // ignore: assay/misspelled_pragma works too. See Suppressions.