How to upload images from url in flutter from firebase storage

Viewed 10

hi I am trying to get an image from firebase storage and show it in my flutter web app but not being able to do so. I am storing the url in the database and trying to call the image when loading the data but getting the error : Failed to load network image. Image URL: https://storage.googleapis.com/biz1/1663760639201.jpg

If someone can please help me resolve this issue.

Please find below the relevant details :

{
    "_id" : ObjectId("63273edd04809866f8e0b9c1"),
    "userId" : 5,
    "name" : "R Singh",
    "profile_pic" : "https://storage.googleapis.com/biz1/1663760639201.jpg",
    
}

profile.dart

child: Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      CircleAvatar(
                        radius: 50.0,
                        backgroundColor: Colors.blue.shade800,
                        backgroundImage: const NetworkImage(
                            'https://storage.googleapis.com/biz1/1663760639201.jpg'),
                        child: const Text('AM'),
                      ),
                      const SizedBox(height: 70),

error message :

Failed to load network image.
Image URL: https://storage.googleapis.com/biz1/1663760639201.jpg
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://storage.googleapis.com/biz1/1663760639201.jpg", scale: 1)
Image key: NetworkImage("https://storage.googleapis.com/biz1/1663760639201.jpg", scale: 1)

storage rules

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if true;
    }
  }
}
0 Answers
Related