Component - Container widget
The Container widget in Flutter is a box that can hold a child widget. It lets you add padding, margins, borders, background color, and size to the child. Think of it like a decorated box that wraps around something.
The Container widget in Flutter is a box that can hold a child widget. It lets you add padding, margins, borders, background color, and size to the child. Think of it like a decorated box that wraps around something.
Scaffold
└── Center
└── Container
└── TextContainer widget in Flutter?width and height properties inside a BoxConstraints via constraints or directly in width and height parameters.size property, constraints: BoxConstraints(width: 100, height: 100) is wrong as BoxConstraints uses minWidth/maxWidth, no dimensions.Container(
width: 100.0,
height: 100.0,
color: Colors.blue,
child: Container(
color: Colors.red,
width: 50,
height: 50,
),
)Container(
padding: EdgeInsets.all(10),
margin: EdgeInsets.symmetric(horizontal: 20),
color: Colors.green,
child: Text('Hello'),
width: 100,
height: 50,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8)),
)color and decoration cannot be used together because color should be inside BoxDecoration if decoration is used.Pass the test and this pattern moves unknown