flutterfirebasefirebase-storagenetworkimageview

Display image in firebase cloud storage as network image in Flutter


I have an image in firebase cloud storage that I want to display in my flutter app using Image.network widget. I am able to get the correct download url from a stroage reference but it is not loading as a network image. I get this error:

Restarted application in 599ms.
══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
The following ImageCodecException was thrown resolving an image codec:
Failed to load network image.
Image URL:
https://firebasestorage.googleapis.com/v0/b/campus-connect-324ef.appspot.com/o/bg1.jpg?alt=media&token=3d593a5d-4842-497e-8a10-09330b226562
Trying to load an image from another domain? Find answers at:
https://flutter.dev/docs/development/platform-integration/web-images
When the exception was thrown, this was the stack
Image provider:
  NetworkImage("https://firebasestorage.googleapis.com/v0/b/campus-connect-324ef.appspot.com/o/bg1.jpg?alt=media&token=3d593a5d-4842-497e-8a10-09330b226562",
  scale: 1)
Image key:
  NetworkImage("https://firebasestorage.googleapis.com/v0/b/campus-connect-324ef.appspot.com/o/bg1.jpg?alt=media&token=3d593a5d-4842-497e-8a10-09330b226562",
  scale: 1)

Thanks in advance

I tried using cached_network_image but it didn't work out either.

getBG() is working fine. Exception in Panorama widget.

void getBG(String name) async {
    final response = await storage.child(name).getDownloadURL();
    setState(() {
      bg = response;
    });
  }

.
.
.

body: Panorama(
        key: UniqueKey(),
        hotspots: hotspots,
        child: Image.network(bg),
      ),

Solution

  • I tried to show image using url from your stacktrace ("https://firebasestorage.googleapis.com/v0/b/campus-connect-324ef.appspot.com/o/bg1.jpg?alt=media&token=3d593a5d-4842-497e-8a10-09330b226562") using Image.network() and NetworkImage widget and working fine but didn't check on browser so if you are checking on browser then try with this solution https://github.com/flutter/flutter/issues/73109#issuecomment-814143539

    If you are checking with ios and android then try to reinstall app or hotrestart as suggested in above link