Why I keep getting this error message although I added the null checking?
if (params.page != null) {
++params.page;
}
Error
The method '+' can't be unconditionally invoked because the receiver can be 'null'.
Try making the call conditional (using '?.') or adding a null check to the target ('!')
3
Answers
You’re probably trying to promote a field that is not private. As per Dart 3.2, type promotion for fields only works when the field is private.
See: Only private fields can be promoted
Try this one
Sure, I can help with that :
1: if ( params.page != null ) { params.page!++ ; // Using the non-null assertion
}
or this
2: if ( params.page != null ) { params.page?.++ ; // Using the non – null
assertion }