showPicture function
Implementation
Widget showPicture(String path, {double height = 150, double? width, Color? color}) {
String imagePath = path;
if (imagePath.contains('.json')) {
return Lottie.asset(
imagePath,
height: height,
width: width,
fit: BoxFit.fitHeight,
);
} else if (!imagePath.contains('http') && imagePath.contains('.png') ||
!imagePath.contains('http') && imagePath.contains('.jpg') && imagePath.contains('.jpeg')) {
return Image.asset(
imagePath,
height: height,
width: width,
color: color,
fit: BoxFit.fitHeight,
);
} else if (imagePath.contains('.svg')) {
log("message path : $imagePath");
return SvgPicture.asset(
imagePath,
height: height,
width: width,
color: color,
fit: BoxFit.contain,
);
} else if (imagePath.contains('http')) {
return Image.network(
imagePath,
height: height,
width: width,
fit: BoxFit.fitHeight,
color: color,
loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) return child;
return VentSkelton(
width: width ?? 0,
height: height,
).shimmer();
},
errorBuilder: (context, error, stackTrace) => const Icon(
Icons.error,
color: Colors.grey,
),
);
}
return FlutterLogo(
size: height,
);
}