Flutter – Display Image from URL

Display Image from URL in Flutter – Image.network()

In this tutorial, we will learn how to display an image from URL, in Flutter Application.

In Flutter, you can display an image from different possible sources. To display an image from URL, you may use Image.network() constructor of Image class.

Sample Code Snippet

Following is a sample code snippet to display an image from the URL https://googleflutter.com/sample_image.jpg.

Image.network('https://googleflutter.com/sample_image.jpg'),

Following is a list of supported Image formats.

  • JPEG
  • PNG
  • GIF
  • Animated GIF
  • WebP
  • Animated WebP
  • BMP
  • WBMP

Example

This is an example Flutter application to demonstrate how to display an image in your Flutter application.

To recreate this example application, create a Flutter application and replace main.dart with the following code.

main.dart

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: MyApp(),
  ));
}

class MyApp extends StatefulWidget {
  @override
  _State createState() => _State();
}

class _State extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Tutorial - googleflutter.com'),
      ),
      body: Center(
          child: Column(children: <Widget>[
            Text('Welcome to Flutter Tutorial on Image'),
            Image.network('https://googleflutter.com/sample_image.jpg'),
          ])),
    );
  }
}

When you run this application on an Android Device or Emulator, you should something similar to the following screenshot.

Summary

In this Flutter Tutorial, we learned how to display an image in Flutter UI Application from URL via network.

Desclaimer: We are not affiliated, associated, authorized, endorsed by, or in any way officially connected with the Google, Apple or Flutter, or any of its subsidiaries or its affiliates. The names Google, Apple and Flutter as well as related names, marks, emblems and images are registered trademarks of their respective owners. This site googleflutter.com covers tutorials related to Flutter developed by Google.