definitely_unassigned_late_local_variable
The late local variable '{0}' is definitely unassigned at this point.
Description
#The analyzer produces this diagnostic when definite assignment analysis
shows that a local variable that's marked as late
is read before being
assigned.
Example
#The following code produces this diagnostic because x
wasn't assigned a
value before being read:
dart
void f(bool b) {
late int x;
print(x);
}
Common fixes
#Assign a value to the variable before reading from it:
dart
void f(bool b) {
late int x;
x = b ? 1 : 0;
print(x);
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。