@@ -2,7 +2,7 @@ import 'package:habr_app/models/author_info.dart';
22import 'package:habr_app/models/models.dart' ;
33import 'package:html/parser.dart' show parseFragment;
44
5- AuthorAvatarInfo prepareAvatarUrl (String url) {
5+ AuthorAvatarInfo prepareAvatarUrl (String ? url) {
66 if (url == null ) return AuthorAvatarInfo (url: null );
77 if (url.startsWith ("//" )) url = url.replaceFirst ("//" , "https://" );
88 return AuthorAvatarInfo (url: url);
@@ -70,11 +70,11 @@ PostPreviews parsePostPreviewsFromJson(Map<String, dynamic> data) {
7070 corporative: article['isCorporative' ],
7171 title: _prepareHtmlString (article['titleHtml' ]),
7272 hubs: article['hubs' ]
73- .map <String >((flow) => flow['title' ] as String )
73+ .map <String >((flow) => flow['title' ] as String ? )
7474 .toList (),
7575 htmlPreview: "<div>${article ['leadData' ]['textHtml' ]}</div>" ,
7676 flows: article['flows' ]
77- .map <String >((flow) => flow['title' ] as String )
77+ .map <String >((flow) => flow['title' ] as String ? )
7878 .toList (),
7979 publishDate: DateTime .parse (article['timePublished' ]),
8080 author: parseAuthorFromJson (article['author' ]),
@@ -99,5 +99,5 @@ AuthorInfo parseAuthorInfoFromJson(Map<String, dynamic> data) {
9999}
100100
101101String _prepareHtmlString (String str) {
102- return parseFragment (str).text.trim ();
102+ return parseFragment (str).text? .trim () ?? '' ;
103103}
0 commit comments