From fea994384c3c81a32d64af2cfa3c6d0d6f2b0700 Mon Sep 17 00:00:00 2001 From: Luca Coduri Date: Thu, 8 Sep 2022 14:30:05 +0200 Subject: [PATCH] fix avatar --- lib/screens/add_meal.dart | 3 ++- lib/widgets/custom_cached_network_image.dart | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/screens/add_meal.dart b/lib/screens/add_meal.dart index bc52f29..d5a714a 100644 --- a/lib/screens/add_meal.dart +++ b/lib/screens/add_meal.dart @@ -1,4 +1,5 @@ import 'package:auto_route/auto_route.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:cross_file_image/cross_file_image.dart'; import 'package:day_night_time_picker/day_night_time_picker.dart'; import 'package:flutter/material.dart'; @@ -89,7 +90,7 @@ class _AddMealScreenState extends State { if (_image != null) { image = XFileImage(_image!); } else { - image = NetworkImage(widget._meal!.photo!); + image = CachedNetworkImageProvider(widget._meal!.photo!); } } else if (_image != null) { image = XFileImage(_image!); diff --git a/lib/widgets/custom_cached_network_image.dart b/lib/widgets/custom_cached_network_image.dart index 5e96147..de0d227 100644 --- a/lib/widgets/custom_cached_network_image.dart +++ b/lib/widgets/custom_cached_network_image.dart @@ -11,7 +11,8 @@ class CustomCachedNetworkImage extends StatelessWidget { imageUrl: imageUrl, progressIndicatorBuilder: (context, url, downloadProgress) => CircularProgressIndicator(value: downloadProgress.progress), - errorWidget: (context, url, error) => const Icon(Icons.error), + errorWidget: (context, url, error) => + Image.asset('assets/images/default_user_pic.png'), imageBuilder: ((context, imageProvider) => Container( decoration: BoxDecoration( shape: BoxShape.circle,