What is container class in Flutter?

· 3 min read
What is container class in Flutter?
What is container class in Flutter?

A Container class is a widget that combines common painting, positioning, and sizing of widgets. So, we will see what is container class in Flutter.

What is container class in Flutter?

A Container class in Flutter stores one or more widgets. So, it positions them on the screen according to your convenience. Basically, a container is like a box to store contents. A basic container element that stores a widget has a margin. It separates the present container from other contents. You can give a border of different shapes to the total container, for example, rounded rectangles, etc. A container surrounds its child with padding. Later it applies additional constraints to the padded extent.

Properties of Container Class:

  • child:  Container widget has a property ‘child:’ which stores its children. The child class can be any widget.
  • color:  The color property sets the background color of the entire container. We can visualize the position of the container using a background color.
  • height and width: By default, a container class takes the space that is required by the child. We can also specify the height and width of the container based on our needs.
  • margin: The margin creates an empty space around the container. Here we can use EdgeInsets.geometry to set the margin. It indicates that margin is present in all four directions equally.
  • padding: The padding will give space from the border of the container to its children.
  • decoration: The decoration property decorates the box (e.g. give a border). This paints behind the child. Whereas foregroundDecoration paints in front of a child.
  • transform: This property of the container helps us to rotate the container. We can rotate the container on any axis.
  • constraints: When we want to give additional constraints to the child, we can use this property.
  • clipBehaviour: This property takes in Clip enum as the object. This decides if the content inside the container will be clipped or not.
  • foregroundDecoration: It holds the Decoration class as the object. It controls the decoration in front of the Container widget.

There are many operations that can be performed to container class. Moreover, the container class is often used while developing flutter applications. These are just the basics of a container class.


Thanks for being with us on a Flutter Journey!

So, in this article, we have seen What is container class in Flutter. Also, feel free to drop us your suggestion/feedback to serve you better.

Flutter Agency is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

Flutter Agency is one of the most popular online portals dedicated to Flutter Technology. Daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.


Leave a Reply