Are there any difference in both of them?
Whats the disadvantage and which one is easier to use for normal situation?
and append the image. Step 4: Now in the body of the scaffold, Create a ListView widget, In ListView first, we will use the row to show the item count and a button. Now add one more child to the listview, which will show the list of images.
Are there any difference in both of them?
Yes. They are different.
src URL passed to it. It is not a widget and does not output an image to the screen.Image.network creates a widget that displays an image on the screen. It is just a named constructor on the Image class(a stateful widget). It sets the image property using the NetworkImage . This image property is used finally to display the image.
class Image extends StatefulWidget{ Image(...){}; //default Constructor //the argument src is passed to the NetworkImage and assinged to the image property Image.network(String src, {...}) : image = NetworkImage(src, ...); final ImageProvider image; @override Widget build(BuildContext context){ display the image return RawImage(image: image, ... ); } } Whats the disadvantage and which one is easier to use for normal situation?
There is no disadvantage. You should use the one the suits the need. For example consider:
backgroundImage. It requires an ImageProvider. So you pass NetworkImage(http://image.com) ImageProvider for its image property. So you can provide it NetworkImage(http://image.com).If you just want to display the image as a widget on screen use Image.network and use NetworkImage wherever an ImageProvider is expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With