fix:按html的假数据demo
This commit is contained in:
@@ -18,12 +18,16 @@ List<String> asStringList(Object? value) {
|
||||
|
||||
JsonMap asMap(Object? value) {
|
||||
if (value is Map<String, dynamic>) return value;
|
||||
if (value is Map) return value.map((key, val) => MapEntry(key.toString(), val));
|
||||
if (value is Map) {
|
||||
return value.map((key, val) => MapEntry(key.toString(), val));
|
||||
}
|
||||
return const {};
|
||||
}
|
||||
|
||||
List<JsonMap> asMapList(Object? value) {
|
||||
if (value is List) return value.map(asMap).where((item) => item.isNotEmpty).toList();
|
||||
if (value is List) {
|
||||
return value.map(asMap).where((item) => item.isNotEmpty).toList();
|
||||
}
|
||||
return const [];
|
||||
}
|
||||
|
||||
@@ -46,6 +50,7 @@ class Institution {
|
||||
required this.id,
|
||||
required this.nameCn,
|
||||
this.nameEn = '',
|
||||
this.logoUrl = '',
|
||||
this.institutionType = '',
|
||||
this.sourceTier = '',
|
||||
this.websiteUrl = '',
|
||||
@@ -60,6 +65,7 @@ class Institution {
|
||||
final String id;
|
||||
final String nameCn;
|
||||
final String nameEn;
|
||||
final String logoUrl;
|
||||
final String institutionType;
|
||||
final String sourceTier;
|
||||
final String websiteUrl;
|
||||
@@ -75,6 +81,7 @@ class Institution {
|
||||
id: asString(json['institution_id']),
|
||||
nameCn: asString(json['name_cn']),
|
||||
nameEn: asString(json['name_en']),
|
||||
logoUrl: asString(json['logo_url']),
|
||||
institutionType: asString(json['institution_type']),
|
||||
sourceTier: asString(json['source_tier']),
|
||||
websiteUrl: asString(json['website_url']),
|
||||
@@ -83,9 +90,9 @@ class Institution {
|
||||
latestReportAt: json['latest_report_at']?.toString(),
|
||||
credibilityNote: asString(json['credibility_note']),
|
||||
introCn: asString(json['intro_cn']),
|
||||
recentReports: asMapList(json['recent_reports'])
|
||||
.map(ReportCardModel.fromJson)
|
||||
.toList(),
|
||||
recentReports: asMapList(
|
||||
json['recent_reports'],
|
||||
).map(ReportCardModel.fromJson).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -161,7 +168,10 @@ class AudioItem {
|
||||
audioId: asString(json['audio_id']),
|
||||
reportId: asString(json['report_id']),
|
||||
titleCn: asString(json['title_cn']),
|
||||
reportTitleCn: asString(json['report_title_cn'], asString(json['title_cn'])),
|
||||
reportTitleCn: asString(
|
||||
json['report_title_cn'],
|
||||
asString(json['title_cn']),
|
||||
),
|
||||
durationSec: asInt(json['duration_sec']),
|
||||
institution: Institution.fromJson(asMap(json['institution'])),
|
||||
releasedAt: json['released_at']?.toString(),
|
||||
|
||||
Reference in New Issue
Block a user