avoid-late-final-reassignment
Warns when a late final
variable is assigned multiple times in the same block.
Assigning to a late final variables multiple times will throw at runtime and should be avoided.
Example
❌ Bad:
class _TestState {
late final String _title;
void initState() {
_title = 'title';
_title = 'another'; // LINT: This late final field is already assigned. Try removing the 'final' modifier or don't reassign the value.
}
}
✅ Good:
class _TestState {
late final String _title;
void initState() {
_title = 'title';
}
}