Skip to content

Latest commit

 

History

History
40 lines (35 loc) · 2.42 KB

File metadata and controls

40 lines (35 loc) · 2.42 KB

A widget that displays an image.

Several constructors are provided for the various ways that an image can be specified:

The following image formats are supported: JPEG, PNG, GIF, Animated GIF, WebP, Animated WebP, BMP, and WBMP. Additional formats may be supported by the underlying platform. Flutter will attempt to call platform API to decode unrecognized formats, and if the platform API supports decoding the image Flutter will be able to render it.

To automatically perform pixel-density-aware asset resolution, specify the image using an AssetImage and make sure that a MaterialApp, WidgetsApp, or MediaQuery widget exists above the Image widget in the widget tree.

Examples

class ExImage extends StatelessWidget {
  const ExImage({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 300,
      height: 300,
      color: Colors.blue.shade100,
      child: Image(
        // image: NetworkImage(
        //   "https://cdn.pixabay.com/photo/2023/08/05/23/40/bird-8171927_1280.jpg",
        // ),
        image: AssetImage("assets/image/food0.png"),
        // fit: BoxFit.cover,
      ),
    );
  }
}