Sitemap

Flutter — BoxFit types

3 min readAug 26, 2022

--

There are seven different fit properties, BoxFit.Contain which is the default property. BoxFit.cover, BoxFit.fill, BoxFit.fitHeight, BoxFit.fitWidth, BoxFit.none, and BoxFit.scaleDown which same as none or contain. We will see examples of all to see how it affects its child differently.

Get Muhammad Omer Shafique’s stories in your inbox

Join Medium for free to get updates from this writer.

BoxFit.contain:- It sets its child to be as large as possible, while still containing the child within the bounds of the parent widget.

Press enter or click to view image in full size

BoxFit.cover:- It sets its child to be as small as possible, while still covering the child within the bounds of the parent widget.

Press enter or click to view image in full size

BoxFit.fill:- The child fills the parent box while also distorting the aspect ratio of the child.

Press enter or click to view image in full size

BoxFit.fitHeight:- It makes sure that the child takes the full height of the parent, and lets the child overflow inside the parent widget horizontally, while still maintaining the aspect ratio.

Press enter or click to view image in full size

BoxFit.fitWidth:- It makes sure that the child takes the full width of the parent, and lets the child overflow inside the parent widget vertically, while still maintaining the aspect ratio.

Press enter or click to view image in full size

Boxfit.none:- It aligns the child inside the parent centering it by default and discards any portion that lies outside the bounds of the parent widget.

Press enter or click to view image in full size

Boxfit.scaleDown:- Similar to none, it ensures to scale the down the child and fit in inside the parent widget. This is same as contain as it shrinks the child to fit inside the parent widget.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.

--

--