minValueOfType function

MinValueFn minValueOfType (
  1. Type type
)

Returns a function that returns the minimum possible non-negative value of an instance of type type.

Implementation

MinValueFn minValueOfType(Type type) {
  Map<Type, MinValueFn> valueFnMap = {
    DateTime: () => DateTime.fromMillisecondsSinceEpoch(0),
    int: () => 0,
    double: () => 0.0,
  };

  if (valueFnMap.containsKey(type)) return valueFnMap[type];

  print('Asked for minValueFn of unknown type: $type, defaulting to () => 0.0');
  return () => 0.0;
}