@@ -189,6 +189,15 @@ class ImageState extends EWidgetState<EnsembleImage> {
189
189
190
190
Widget buildNonSvgImage (String source, BoxFit ? fit) {
191
191
if (source.startsWith ('https://' ) || source.startsWith ('http://' )) {
192
+ // If the asset is available locally, then use local path
193
+ String assetName = Utils .getAssetName (source);
194
+ if (Utils .isAssetAvailableLocally (assetName)) {
195
+ return Image .asset (Utils .getLocalAssetFullPath (assetName),
196
+ width: widget._controller.width? .toDouble (),
197
+ height: widget._controller.height? .toDouble (),
198
+ fit: fit,
199
+ errorBuilder: (context, error, stacktrace) => errorFallback ());
200
+ }
192
201
int ? cachedWidth = widget._controller.resizedWidth;
193
202
int ? cachedHeight = widget._controller.resizedHeight;
194
203
@@ -273,9 +282,18 @@ class ImageState extends EWidgetState<EnsembleImage> {
273
282
fit: fit ?? BoxFit .contain,
274
283
);
275
284
}
276
-
285
+
277
286
// if is URL
278
287
if (source.startsWith ('https://' ) || source.startsWith ('http://' )) {
288
+ // If the asset is available locally, then use local path
289
+ String assetName = Utils .getAssetName (source);
290
+ if (Utils .isAssetAvailableLocally (assetName)) {
291
+ return SvgPicture .asset (
292
+ Utils .getLocalAssetFullPath (assetName),
293
+ width: widget._controller.width? .toDouble (),
294
+ height: widget._controller.height? .toDouble (),
295
+ fit: fit ?? BoxFit .contain);
296
+ }
279
297
return SvgPicture .network (
280
298
widget._controller.source,
281
299
width: widget._controller.width? .toDouble (),
0 commit comments