urlToImage function
Implementation
Widget urlToImage(String? link, {double? width, double? height}) {
Widget inner = Container();
if (link == null) {
return SizedBox(
width: width,
height: height,
child: inner,
);
} else {
final url = Uri.tryParse(link);
if (url == null) {
return SizedBox(
width: width,
height: height,
child: inner,
);
}
if (url.data != null && url.data!.isBase64) {
inner = Image.memory(url.data!.contentAsBytes(), gaplessPlayback: true);
} else if (url.isAbsolute) {
if (UrlTypeHelper.getType(url) == UrlType.video) {
inner = VideoWidget(uri: url);
} else {
inner = Image.network(link, gaplessPlayback: true);
}
}
return SizedBox(
width: width,
height: height,
child: inner,
);
}
}