Home > Blockchain >  I want a image but nither assest image nor network image is loading on screen
I want a image but nither assest image nor network image is loading on screen

Time:01-17

image is not loading in output in my screen .soo plz anyone help me in solving this

  Container(
   decoration: const BoxDecoration(
     image:DecorationImage(image: NetworkImage(''))
   ),
 )

CodePudding user response:

Check if you added your image into the pubspec.yaml file like this:

assets: 
- images/image1.jpeg
- images/icon.png

I suggest use the child of the Container and not the decoration. Also, you could use Image.Asset instead, specifing height or/and height:

Image.asset('images/icon.png', height: 20)

Documentation here and here

CodePudding user response:

If you want to load images from network then please use below package , So if there is an error in your image loading time , you will easily identify where your code is not working.

Package :- Cached Network Image

Please find an sample example of above package.

CachedNetworkImage(
 imageUrl: "",       // your network image link at here
 placeholder: (context, url) => new CircularProgressIndicator(),
  errorWidget: (context, url, error) => new Icon(Icons.error),
),

CodePudding user response:

Generally Network Images on flutter takes time to appear.

But if it still continues then Check Internet Permission setting in andoidmanifes.xml file

CodePudding user response:

Using Asset image is not a good solution because it makes the app size larger.. The solution is that you need to use:

Container(
child: Image.network('') //your image source
)

And if that is not the case.. the image you are using is invalid but not exactly invalid. Meaning it does not end with an image format in the end.. like (.jpg,.png etc.)

CodePudding user response:

Add your image into an assets folder and specify it inside the pubspec.yaml file. Specify the image file

Container(
   decoration: const BoxDecoration(
     image:DecorationImage(image: NetworkImage('assets/image.png'))
   ),
 )

Restart the application after performing pub get inside the root directory.

  •  Tags:  
  • Related