this code runs fine without null safety:
void main() {
final a = X(22.5);
final b = X(22.5);
List<X> x = [a, b];
var tot = x.fold(0.0, (a, b) => a + b.dist);
print(tot);
}
class X {
final double dist;
X(this.dist);
}
with null safety we get:
The operator '+' can't be unconditionally invoked because the receiver can be 'null'. Try adding a null check to the target ('!').
No idea who/what the target is or the receiver for that matter. I've read all the Dart material on null safety and can't get this to build as an arrow expression ( => a + b.dist).
Thanks for any help!