measureFnForType function

MeasureFn measureFnForType (
  1. Type type
)

Returns a function that returns the measurement of a given type T.

Implementation

MeasureFn measureFnForType(Type type) {
  Map<Type, MeasureFn> measureFnMap = {
    DateTime: (date) => date.millisecondsSinceEpoch.toDouble(),
    int: (val) => val.toDouble(),
    double: (val) => val,
  };

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

  print('Asked to measure unknown type: $type, defaulting to cast to double');
  return (val) => val as double;
}