Flutter has an Image widget to display different types of images. To display images from the internet, the Image.network() function is used.
Syntax: Image.netwok (source_URL)
Properties Of Image Widget:
- height: This property takes in an integer value as the object. It decides the height of the image vertically.
- width: This property also takes in an Int value as the object to determine the width in pixels to be allocated to the image.
Follow the below steps to display the images from the internet in your Flutter application:
Step 1: Create a new flutter application in the required directory using the below command:
flutter create <app_name>
Step 2: Now, delete the code from main.dart file to add your own code.
Step 3: Now, use the below code in the main.dart file and change the parameter of Image.network function as per you need.
- Here we used the ListView to display images on the screen.
- In Image.network(src), we have given the network image path (src is image path).
- Finally, we used the width and height to resize the image.