getNumByValueDouble static method

num? getNumByValueDouble(
  1. double? value,
  2. int fractionDigits
)

The parameter fractionDigits must be an integer satisfying: 0 <= fractionDigits <= 20.

Implementation

static num? getNumByValueDouble(double? value, int fractionDigits) {
  if (value == null) return null;
  String valueStr = value.toStringAsFixed(fractionDigits);
  return fractionDigits == 0
      ? int.tryParse(valueStr)
      : double.tryParse(valueStr);
}