mirror of
https://github.com/Shchoholiev/shopping-assistant-mobile-client.git
synced 2025-04-05 00:59:38 +00:00
Changed method for displaying images
This commit is contained in:
parent
a99e181412
commit
d1e8f3c4f2
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:graphql/client.dart';
|
import 'package:graphql/client.dart';
|
||||||
@ -177,22 +178,10 @@ class CartItem extends StatelessWidget{
|
|||||||
Container(
|
Container(
|
||||||
width: 100,
|
width: 100,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Image.network(
|
child: CachedNetworkImage(
|
||||||
_product.imageUrls[0],
|
imageUrl: _product.imageUrls[0],
|
||||||
loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) {
|
placeholder: (context, url) => CircularProgressIndicator(),
|
||||||
if (loadingProgress == null) return child;
|
errorWidget: (context, url, error) => Image.asset('../assets/img/default-white.png'),
|
||||||
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),
|
SizedBox(width: 20),
|
||||||
|
Loading…
Reference in New Issue
Block a user