The method '+' can't be unconditionally invoked because the receiver can be 'null'. Flutter Dart - TagMerge
3The method '+' can't be unconditionally invoked because the receiver can be 'null'. Flutter DartThe method '+' can't be unconditionally invoked because the receiver can be 'null'. Flutter Dart

The method '+' can't be unconditionally invoked because the receiver can be 'null'. Flutter Dart

Asked 1 years ago
2
3 answers

Are you initializing the value anywhere before the + call ? Otherwise you are just adding to null on the first call. If you are initializing with a non null value before that line somewhere, you call add ! to your totalSum on the line where you use +=.

Otherwise as Josteve said, just mark as non nullable with an initial value.

Source: link

1

Try declaring totalSum as non-nullable like:

double totalSum = 0;

or

totalSum! += recentTransactions[i].amount;

Source: link

0

Try this:

double totalSum = 0;

Source: link

Recent Questions on flutter

    Programming Languages