WorkoutModel.fromJson constructor

WorkoutModel.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory WorkoutModel.fromJson(Map<String, dynamic> json) {
  return WorkoutModel(
    id: json['id'] as String? ?? '',
    title: json['title'] as String? ?? '',
    imgURL: json['workout_desc_img'] as String? ?? '',
    category: json['category'] as String?,
    description: json['description'] as String? ?? '',
    totalMinutes: json['total_minutes'] as int?,
    totalCalories: json['calories'] as int?,
    bodyParts: (json['body_parts'] as List<dynamic>?)
            ?.map((e) => e.toString())
            .toList() ??
        [],
    difficultyLevel: json['dif_level'] as String?,
    equipment: _parseEquipmentList(json['equipment'] as List<dynamic>?),
    sequence: (json['sequence'] as List<dynamic>?)
            ?.map((e) => ExerciseModel.fromJson(e as Map<String, dynamic>))
            .toList() ??
        [],
    rawJSON: json,
  );
}