import 'ny_drama_model.dart'; class NyHomeModel { final String? moduleKey; final List dataList; const NyHomeModel({required this.moduleKey, required this.dataList}); factory NyHomeModel.fromJson(Map json) { final data = json['data']; List videos = []; if (data is Map) { final list = data['list']; if (list is List) { videos = list.map((e) => NyDramaModel.fromJson(e)).toList(); } } else if (data is List) { videos = data.map((e) => NyDramaModel.fromJson(e)).toList(); } return NyHomeModel( moduleKey: json['module_key'] as String?, dataList: videos, ); } Map toJson() { return {'module_key': moduleKey, 'dataList': dataList}; } NyHomeModel copyWith({String? moduleKey, dynamic data}) { return NyHomeModel( moduleKey: moduleKey ?? this.moduleKey, dataList: data ?? dataList, ); } }