Basic layout operations: Setting container width

Setting container width

Var container = Container( // grey box
  child: Center(
    child: Container( // red box
      child: Text(
        "Lorem ipsum",
        style: bold24Roboto,
      ),
      decoration: BoxDecoration(
        color: Colors.red[400],
      ),
      padding: EdgeInsets.all(16),
      width: 240, //max-width is 240
    ),
  ),
  width: 320, 
  height: 240,
  color: Colors.grey[300],
);

To specify the width of a Container widget, use its width property.

To mimic that effect in Flutter, use the constraints property of the Container. Create a new BoxConstraints widget with a minWidth or maxWidth.

Related concepts

Basic layout operations: Setting container width — Structure map

Clickable & Draggable!

Basic layout operations: Setting container width — Related pages: