import 'package:workouttest_util/model/tutorial_step.dart'; enum TutorialEnum { basic, development, training } class Tutorial { late int tutorialId; late String name; List? steps; Tutorial.fromJson(Map json) { this.tutorialId = json['tutorialId']; this.name = json['name']; if (json['steps'] != null && json['steps'].length > 0) { steps = json['steps'].map((step) => TutorialStep.fromJson(step)).toList(); if (steps != null) { steps!.sort((a, b) { if (a.step == null || b.step == null) { return -1; } else { if (a.step! <= b.step!) { return -1; } else { return 1; } } }); } } } Map toJson() => {'tutorialId': this.tutorialId, 'name': this.name, 'steps': steps.toString()}; @override String toString() => this.toJson().toString(); }