From 3a0622939e8188c8986f31f396f3b3319e8e82cc Mon Sep 17 00:00:00 2001 From: MohammadTaha Basiri Date: Sun, 3 Apr 2022 00:29:53 +0430 Subject: [PATCH] podcast overview --- lib/models/overview_data.dart | 50 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/models/overview_data.dart b/lib/models/overview_data.dart index 6a20c71..beba572 100644 --- a/lib/models/overview_data.dart +++ b/lib/models/overview_data.dart @@ -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 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.from( - json['categories'].map( - (e) => CategoryData.fromJson(e), - ), - ) - : null, - ); + factory OverviewData.fromJson(Map 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.from( + json['categories'].map( + (e) => CategoryData.fromJson(e), + ), + ) + : null, + ); + } Map toJson() => { 'id': id,