TripInsights.fromJson constructor

TripInsights.fromJson(
  1. Map<String, dynamic> jsonDecode
)

Implementation

TripInsights.fromJson(Map<String, dynamic> jsonDecode) {
  appTripId = jsonDecode['appTripId'];

  safety = extractFromNullableModel(
    jsonDecode['safety'],
    SafetyInsights,
  );

  performance = extractFromNullableModel(
    jsonDecode['performance'],
    PerformanceInsights,
  );

  efficiency = extractFromNullableModel(
    jsonDecode['efficiency'],
    EfficiencyInsights,
  );

  contextual = extractFromNullableModel(
    jsonDecode['contextual'],
    ContextualInsights,
  );

  comparative = extractFromNullableModel(
    jsonDecode['comparative'],
    ComparativeInsights,
  );

  summary = (jsonDecode['summary'] as List?)
      ?.map((e) => e?.toString())
      .toList();
}