DeepSource has joined Harness. Learn more
Dart Analyze logoDart Analyze/
DRT-W1293

Unassigned late local variable is definitely unassigned at this pointDRT-W1293

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when C interop using dart:ffi 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:

void f(bool b) {
  late int x;
  print(x);
}

Common fixes

Assign a value to the variable before reading from it:

void f(bool b) {
  late int x;
  x = b ? 1 : 0;
  print(x);
}