novyronst/lib/common/model/ny_home_model.dart

40 lines
983 B
Dart

import 'ny_drama_model.dart';
class NyHomeModel {
final String? moduleKey;
final List<NyDramaModel> dataList;
const NyHomeModel({required this.moduleKey, required this.dataList});
factory NyHomeModel.fromJson(Map<String, dynamic> json) {
final data = json['data'];
List<NyDramaModel> videos = [];
if (data is Map<String, dynamic>) {
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<String, dynamic> toJson() {
return {'module_key': moduleKey, 'dataList': dataList};
}
NyHomeModel copyWith({String? moduleKey, dynamic data}) {
return NyHomeModel(
moduleKey: moduleKey ?? this.moduleKey,
dataList: data ?? dataList,
);
}
}