tryFromMap static method

MetricResult? tryFromMap(
  1. Map<String, dynamic> mapData
)

Implementation

static MetricResult? tryFromMap(Map<String, dynamic> mapData) {
  final key = mapData['key']?.toString();
  final type = mapData['type']?.toString();
  if (key == null || key.isEmpty || type == null || type.isEmpty) {
    return null;
  }

  return MetricResult(
    key: key,
    type: type,
    count: mapData['count']?.toInt() ?? 1,
    duration: mapData['duration']?.toInt() ?? 0,
    dimensions: mapData['dimensions'] as Map<String, dynamic>? ?? {},
  );
}