Displaying images is fundamental for most mobile apps. Flutter provides theImage Widget todisplay different types of images.

In order to work with images from a URL, use theImage.networkconstructor.

  1. Image.network(
  2. 'https://picsum.photos/250?image=9',
  3. )

Bonus: Animated Gifs

One amazing thing about the Image Widget: It also supports animated gifs outof the box!

  1. Image.network(
  2. 'https://github.com/flutter/plugins/raw/master/packages/video_player/doc/demo_ipod.gif?raw=true',
  3. );

Placeholders and Caching

The default Image.network constructor does not handle more advancedfunctionality, such as fading images in after loading or caching imagesto the device after they’re downloaded. To achieve these tasks, please seethe following recipes:

Complete example

  1. import 'package:flutter/material.dart';
  2. void main() => runApp(MyApp());
  3. class MyApp extends StatelessWidget {
  4. @override
  5. Widget build(BuildContext context) {
  6. var title = 'Web Images';
  7. return MaterialApp(
  8. title: title,
  9. home: Scaffold(
  10. appBar: AppBar(
  11. title: Text(title),
  12. ),
  13. body: Image.network(
  14. 'https://picsum.photos/250?image=9',
  15. ),
  16. ),
  17. );
  18. }
  19. }

Network Image Demo