Skip to content

Instantly share code, notes, and snippets.

@thuycom205
Created December 26, 2022 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thuycom205/8a7791b4951dd37f4c1244822384088c to your computer and use it in GitHub Desktop.
Save thuycom205/8a7791b4951dd37f4c1244822384088c to your computer and use it in GitHub Desktop.
CacheImage buildCacheImage() {
if(item.product!.productType == ProductType.Configurable){
if(item.product!.variants!=null&&item.product!.variants!.length > 0){
if(item.product!.variants!.first.product!=null&&
item.product!.variants!.first.product!.mediaGallery!=null&&
item.product!.variants!.first.product!.mediaGallery!.isNotEmpty){
return CacheImage(
imageUrl: item.product!.variants!.first.product!.mediaGallery!.first.url??"",
boxFit: BoxFit.cover,
);
}else{
return CacheImage(
imageUrl: item.product!.image?.url ?? "",
boxFit: BoxFit.cover,
);
}
}else{
return CacheImage(
imageUrl: item.product!.image?.url ?? "",
boxFit: BoxFit.cover,
);
}
}
return CacheImage(
imageUrl: item.product!.image?.url ?? "",
boxFit: BoxFit.cover,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment