numToNumber function

Number numToNumber(
  1. num value
)

Converts a num value to associated Number object (Integer for ints and doubles that have an integer value, Double for other doubles).

Implementation

Number numToNumber(num value) {
  if (value is int) return Integer(value);
  if (value.toInt() == value) return Integer(value.toInt());
  return Double(value.toDouble());
}