image static method
Providing the right provider by choosing between in-network and assets.
Get the provider for the image.
uri
is if it starts with http, get a network image,
otherwise get an asset image.
defaultURI
is the path to be read from the asset when uri
is empty.
Implementation
static ImageProvider image(String uri,
[String defaultURI = "assets/default.png"]) {
if (uri.isEmpty) {
return _MemoizedAssetImage(defaultURI);
}
if (uri.startsWith("http") || uri.startsWith("blob:")) {
return _MemoizedNetworkImage(uri);
} else if (uri.startsWith("resource:")) {
return _MemoizedAssetImage(uri.replaceAll(RegExp(r"resource:(//)?"), ""));
} else {
return _MemoizedAssetImage(uri);
}
}