Skip to main content

avoid-unassigned-fields

effort: 4m
teams+

Warns when a private field is not assigned a value.

Example

❌ Bad:

class Test {
final _field = 'string';

// LINT: This field is never assigned a value within its declaration.
// Try assigning a value or removing this field.
int? _privateLate;
}

✅ Good:

class Test {
final field = 'string';

int? _anotherField; // Correct, assigned

final String regular; // Correct, not late

Test(this.regular) : _anotherField = 1;
}

Additional Resources