Hi!
So, how to manage this error?
Exception: type 'int' is not a subtype of type 'double?
Working with weather API services has this big incovenient. Sometimes, e.g. temperature, can return a value as double (33.2) ou as integer (33)
And if you had previously declared your Firestore document field as double type, this error will occurr.
And I've tried to apply this function before the Update Firestore Action to work that out but it wasn't succesful:
double? convertIntToDouble(double? intOrDouble) {
/// MODIFY CODE ONLY BELOW THIS LINE
// convert a number, if integer, to a double, if not null
if (intOrDouble == null) {
return null;
} else if (intOrDouble is int) {
return intOrDouble.toDouble();
} else {
return intOrDouble;
}
/// MODIFY CODE ONLY ABOVE THIS LINE
}
So, what now?
Thanks in advance