Image Widget

What is Image Widget?

The Image widget is to display an image.

Default Constructor

The default constructor creates a widget that displays an image.

Image(
      image: // Add Image widget here
)

Constructor Parameters

It contains many input parameters which can be configured to change its behavior and appearance.

The image parameter is to image to display.

Code snippet

The following code snippet shows how to configure Image widget.

Image(
      image: NetworkImage(
          'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg'),
    );

Demo Code

This example shows how to use ImageProvider, such as a NetworkImage, to display an image from the internet.

import 'package:flutter/material.dart';

class ImageDemo extends StatelessWidget {
  
  Widget build(BuildContext context) {
    return const Image(
      image: NetworkImage(
          'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg'),
    );
  }
}

class MyApp extends StatelessWidget {
  static const String _title = 'Image Widget';

  
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(
          title: const Text(_title),
        ),
        body: ImageDemo(),
      ),
    );
  }
}

void main() => runApp(MyApp());