78 lines
1.8 KiB
Dart
78 lines
1.8 KiB
Dart
// Author: fengshengxiong
|
|
// Date: 2024/6/20
|
|
// Description: 首页实际展示数据模型
|
|
|
|
import 'dart:convert';
|
|
|
|
class HomeModel {
|
|
String? headerTitle;
|
|
List<Content>? contents;
|
|
String? browseType;
|
|
|
|
HomeModel({
|
|
this.headerTitle,
|
|
this.contents,
|
|
this.browseType,
|
|
});
|
|
|
|
factory HomeModel.fromJson(String str) => HomeModel.fromMap(json.decode(str));
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
factory HomeModel.fromMap(Map<String, dynamic> json) => HomeModel(
|
|
headerTitle: json["headerTitle"],
|
|
contents: json["contents"] == null ? [] : List<Content>.from(json["contents"]!.map((x) => Content.fromMap(x))),
|
|
browseType: json["browseType"]
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"headerTitle": headerTitle,
|
|
"contents": contents == null ? [] : List<dynamic>.from(contents!.map((x) => x.toMap())),
|
|
"browseType": browseType,
|
|
};
|
|
}
|
|
|
|
class Content {
|
|
String? title;
|
|
String? subTitle;
|
|
String? thumbnail;
|
|
String? videoId;
|
|
String? playlistId;
|
|
String? browseId;
|
|
String? params;
|
|
|
|
Content({
|
|
this.title,
|
|
this.subTitle,
|
|
this.thumbnail,
|
|
this.videoId,
|
|
this.playlistId,
|
|
this.browseId,
|
|
this.params,
|
|
});
|
|
|
|
factory Content.fromJson(String str) => Content.fromMap(json.decode(str));
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
factory Content.fromMap(Map<String, dynamic> json) => Content(
|
|
title: json["title"],
|
|
subTitle: json["subTitle"],
|
|
thumbnail: json["thumbnail"],
|
|
videoId: json["videoId"],
|
|
playlistId: json["playlistId"],
|
|
browseId: json["browseId"],
|
|
params: json["params"],
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"title": title,
|
|
"subTitle": subTitle,
|
|
"thumbnail": thumbnail,
|
|
"videoId": videoId,
|
|
"playlistId": playlistId,
|
|
"browseId": browseId,
|
|
"params": params,
|
|
};
|
|
}
|