From 6cbe514192a76d00c8a57f30a235d50f83a3c2c2 Mon Sep 17 00:00:00 2001 From: Mykyta Dubovyi Date: Mon, 18 Dec 2023 23:56:17 +0200 Subject: [PATCH] default image added --- assets/img/default-white.png | Bin 0 -> 1145 bytes lib/screens/cart.dart | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 assets/img/default-white.png diff --git a/assets/img/default-white.png b/assets/img/default-white.png new file mode 100644 index 0000000000000000000000000000000000000000..d13a4df7070961f8659464db2b3edbef71aa9fab GIT binary patch literal 1145 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k2}mkgS)K$^Ea{HEjtmSN`?>!lvI4mVo-U3d z6>)E`ZWLrtK-Vt>Z}%gv&mA_a|U$M4Lv+{?8_{72$ftqpMx*65o>G=Ap|Tgc?n zm>?K>`%O}6gXV>!NxNQ!H!oE`z``MRIds32jxD2_!-g5_eqBv?$!WmYbhPB^dNyzW z22KH;WvlBS-kmpq~d}#z_NtF)78&qol`;+05&Yw4*&oF literal 0 HcmV?d00001 diff --git a/lib/screens/cart.dart b/lib/screens/cart.dart index 015f790..2e3cb05 100644 --- a/lib/screens/cart.dart +++ b/lib/screens/cart.dart @@ -177,7 +177,23 @@ class CartItem extends StatelessWidget{ Container( width: 100, alignment: Alignment.center, - child: Image(image: NetworkImage(_product.imageUrls[0]),), + child: Image.network( + _product.imageUrls[0], + loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: loadingProgress.expectedTotalBytes != null + ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! + : null, + ), + ); + }, + errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { + // Повертає зображення за замовчуванням у випадку помилки + return Image.asset('../assets/img/default-white.png'); + }, + ), ), SizedBox(width: 20), Expanded(