podcast overview

This commit is contained in:
MohammadTaha Basiri 2022-04-03 00:29:53 +04:30
parent 7f0d0689f8
commit 3a0622939e
1 changed files with 28 additions and 22 deletions

View File

@ -1,4 +1,5 @@
import 'package:didvan/models/category.dart';
import 'package:html/parser.dart';
class OverviewData {
final int id;
@ -33,28 +34,33 @@ class OverviewData {
this.categories,
});
factory OverviewData.fromJson(Map<String, dynamic> json) => OverviewData(
id: json['id'],
title: json['title'],
image: json['image'],
description: json['description'],
timeToRead: json['timeToRead'],
reference: json['reference'],
forManagers: json['forManagers'] ?? false,
comments: json['comments'] ?? 0,
createdAt: json['createdAt'],
duration: json['duration'],
type: json['type'] ?? '',
marked: json['marked'] ?? true,
media: json['media'],
categories: json['categories'] != null
? List<CategoryData>.from(
json['categories'].map(
(e) => CategoryData.fromJson(e),
),
)
: null,
);
factory OverviewData.fromJson(Map<String, dynamic> json) {
final document = parse(json['description']);
final String parsedString =
parse(document.body!.text).documentElement!.text;
return OverviewData(
id: json['id'],
title: json['title'],
image: json['image'],
description: parsedString,
timeToRead: json['timeToRead'],
reference: json['reference'],
forManagers: json['forManagers'] ?? false,
comments: json['comments'] ?? 0,
createdAt: json['createdAt'],
duration: json['duration'],
type: json['type'] ?? '',
marked: json['marked'] ?? true,
media: json['media'],
categories: json['categories'] != null
? List<CategoryData>.from(
json['categories'].map(
(e) => CategoryData.fromJson(e),
),
)
: null,
);
}
Map<String, dynamic> toJson() => {
'id': id,