I'm encountering an error in my Flutter app when trying to log the Change object in the onChange method of my Cubit. The error message is as follows:
Error: The argument type 'String' can't be assigned to the parameter type 'num'
This error is pointing to the line where I'm logging the Change object using log(change.toString());. I understand that this error occurs because I'm trying to log a String as a num, which is not allowed in Dart.
I want to understand how to correctly log the Change object as a `String without encountering this error.
Here's the relevant code snippet: '''
@override
void onChange(Change<PaymentState> change) {
log(change.toString()); // Error occurs on this line
super.onChange(change);
}
I would appreciate any insights or suggestions on how to resolve this error and correctly log the Change object as a `String in Flutter.
Use
debugPrint()likedebugPrnt(change.toString())Edit
debugPrint(String?, {int? wrapWidth})is a function of package:flutter/src/foundation/print.dart.For dart use
print(Object? object)