class VideoZoneItem { const VideoZoneItem({ required this.id, required this.name, required this.coverUrl, required this.videoUrl, required this.accessible, required this.completed, required this.durationSeconds, required this.progressSeconds, required this.lastPlayTime, }); factory VideoZoneItem.fromJson(Map json) { int toInt(dynamic value) => value is num ? value.toInt() : int.tryParse('$value') ?? 0; bool toBool(dynamic value) => value == true || value == 1 || value?.toString() == 'true'; return VideoZoneItem( id: toInt(json['id']), name: json['name']?.toString() ?? '', coverUrl: json['coverUrl']?.toString() ?? '', videoUrl: json['videoUrl']?.toString() ?? '', accessible: toBool(json['accessible']), completed: toBool(json['completed']), durationSeconds: toInt(json['durationSeconds']), progressSeconds: toInt(json['progressSeconds']), lastPlayTime: json['lastPlayTime']?.toString() ?? '', ); } final int id; final String name; final String coverUrl; final String videoUrl; final bool accessible; final bool completed; final int durationSeconds; final int progressSeconds; final String lastPlayTime; String get title => name; }