How to show fullscreen image in flutter

Your problem is that Center will make the image to get it's preferred size instead of the full size. The correct approach would be instead to force the image to expand.

return new Scaffold(
  body: new Image.network(
    "https://cdn.pixabay.com/photo/2017/02/21/21/13/unicorn-2087450_1280.png",
    fit: BoxFit.cover,
    height: double.infinity,
    width: double.infinity,
    alignment: Alignment.center,
  ),
);

The alignment: Alignment.center is unnecessary. But since you used the Center widget, I tought it would be interesting to know how to customize it.


This is another option:

return new DecoratedBox(
  decoration: new BoxDecoration(
    image: new DecorationImage(
      image: new AssetImage('images/lake.jpg'),
      fit: BoxFit.fill

    ),
  ),
);

Tags:

Dart

Flutter