numToNumber function
Converts a num value
to associated Number object
(Integer for int
s and double
s that have an integer value,
Double for other double
s).
Implementation
Number numToNumber(num value) {
if (value is int) return Integer(value);
if (value.toInt() == value) return Integer(value.toInt());
return Double(value.toDouble());
}