From 1e0fcf9c67626f877f09b3e6061ed58ace5a3520 Mon Sep 17 00:00:00 2001 From: krawieck Date: Sun, 13 Sep 2020 16:05:17 +0200 Subject: [PATCH] Fill errorWidget field on every cached network image, cuz otherwise they would break the app --- lib/pages/community.dart | 6 +++++- lib/pages/instance.dart | 18 ++++++++++++++---- lib/pages/users_list.dart | 2 ++ lib/widgets/comment.dart | 1 + lib/widgets/post.dart | 1 + lib/widgets/user_profile.dart | 2 ++ 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/pages/community.dart b/lib/pages/community.dart index 628b500..0f14cc2 100644 --- a/lib/pages/community.dart +++ b/lib/pages/community.dart @@ -265,6 +265,7 @@ class _CommunityOverview extends StatelessWidget { ), ), ), + errorWidget: (_, __, ___) => Icon(Icons.warning), ), ), ), @@ -277,7 +278,10 @@ class _CommunityOverview extends StatelessWidget { if (community.banner != null) FullscreenableImage( url: community.banner, - child: CachedNetworkImage(imageUrl: community.banner), + child: CachedNetworkImage( + imageUrl: community.banner, + errorWidget: (_, __, ___) => Container(), + ), ), SafeArea( child: Padding( diff --git a/lib/pages/instance.dart b/lib/pages/instance.dart index 529c439..d8ec37f 100644 --- a/lib/pages/instance.dart +++ b/lib/pages/instance.dart @@ -162,7 +162,10 @@ class InstancePage extends HookWidget { if (site.site.banner != null) FullscreenableImage( url: site.site.banner, - child: CachedNetworkImage(imageUrl: site.site.banner), + child: CachedNetworkImage( + imageUrl: site.site.banner, + errorWidget: (_, __, ___) => Container(), + ), ), SafeArea( child: Center( @@ -173,9 +176,12 @@ class InstancePage extends HookWidget { child: FullscreenableImage( url: site.site.icon, child: CachedNetworkImage( - width: 100, - height: 100, - imageUrl: site.site.icon), + width: 100, + height: 100, + imageUrl: site.site.icon, + errorWidget: (_, __, ___) => + Icon(Icons.warning), + ), ), ), Text(site.site.name, @@ -332,6 +338,8 @@ class _AboutTab extends HookWidget { height: 50, width: 50, imageUrl: e.icon, + errorWidget: (_, __, ___) => + SizedBox(width: 50, height: 50), imageBuilder: (context, imageProvider) => Container( decoration: BoxDecoration( shape: BoxShape.circle, @@ -380,6 +388,8 @@ class _AboutTab extends HookWidget { height: 50, width: 50, imageUrl: e.avatar, + errorWidget: (_, __, ___) => + SizedBox(width: 50, height: 50), imageBuilder: (context, imageProvider) => Container( decoration: BoxDecoration( shape: BoxShape.circle, diff --git a/lib/pages/users_list.dart b/lib/pages/users_list.dart index 16b5259..332b43c 100644 --- a/lib/pages/users_list.dart +++ b/lib/pages/users_list.dart @@ -48,6 +48,8 @@ class UsersListPage extends StatelessWidget { height: 50, width: 50, imageUrl: users[i].avatar, + errorWidget: (_, __, ___) => + SizedBox(height: 50, width: 50), imageBuilder: (context, imageProvider) => Container( decoration: BoxDecoration( shape: BoxShape.circle, diff --git a/lib/widgets/comment.dart b/lib/widgets/comment.dart index 1ae29d6..206c9ec 100644 --- a/lib/widgets/comment.dart +++ b/lib/widgets/comment.dart @@ -200,6 +200,7 @@ class Comment extends StatelessWidget { ), ), ), + errorWidget: (_, __, ___) => Container(), ), ), ), diff --git a/lib/widgets/post.dart b/lib/widgets/post.dart index 2a4ec37..40614a9 100644 --- a/lib/widgets/post.dart +++ b/lib/widgets/post.dart @@ -374,6 +374,7 @@ class Post extends StatelessWidget { url: post.url, child: CachedNetworkImage( imageUrl: post.url, + errorWidget: (_, __, ___) => Icon(Icons.warning), progressIndicatorBuilder: (context, url, progress) => CircularProgressIndicator(value: progress.progress), ), diff --git a/lib/widgets/user_profile.dart b/lib/widgets/user_profile.dart index 346205d..f5afc3a 100644 --- a/lib/widgets/user_profile.dart +++ b/lib/widgets/user_profile.dart @@ -96,6 +96,7 @@ class UserProfile extends HookWidget { if (userViewSnap.data?.banner != null) CachedNetworkImage( imageUrl: userViewSnap.data.banner, + errorWidget: (_, __, ___) => Container(), ) else Container( @@ -154,6 +155,7 @@ class UserProfile extends HookWidget { borderRadius: BorderRadius.all(Radius.circular(12)), child: CachedNetworkImage( imageUrl: userViewSnap.data.avatar, + errorWidget: (_, __, ___) => Container(), ), ), ),