MissingConstRule class
Detects widget constructor invocations that could be marked const but
aren't.
Const widgets are cached and never rebuilt, so missing const is one of
the most common (and easiest to fix) performance issues in Flutter apps.
What this catches
Text("Hello") // BAD — flagged
SizedBox(height: 16) // BAD — flagged
EdgeInsets.all(8) // BAD — flagged
What this allows
const Text("Hello") // already const
Text(name) // non-const arg — can't be const
Text("Hello $name") // string interpolation — not constant
Constructors
Properties
- category → String
-
Category bucket for grouping in the report.
One of: architecture, performance, memory, ui, api, security, quality.
no setteroverride
- defaultSeverity → Severity
-
Default severity if not overridden by
.flutter_audit.yaml.no setteroverride - description → String
-
One-line description shown in
flutter_audit rulesoutput.no setteroverride - hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Stable, snake_case identifier shown in reports and config files.
Example:
'missing_const'.no setteroverride - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
check(
ParsedFile file) → List< Issue> -
Inspect a parsed file and return any findings.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited