asNum method
Converts the dynamic value to a num (either int or double).
If conversion fails, returns the provided default value or 0.
def The default value to return if conversion fails.
Returns the num representation of the dynamic value or the default value.
Implementation
num asNum({num? def}) {
return num.tryParse(toString()) ?? def ?? 0;
}