'The behavior when putting Row into ConstrainedBox with Flutter is strange

When I put a Row in the ConstrainedBox with Flutter, the display is out of the way. Is this a Flutter bug?

//Does not Stick out Pattern

ConstrainedBox(
  constraints: BoxConstraints(
  maxWidth: ScreenUtil.getFullWidth(context) * 0.8),
  child: Container(
    decoration: const BoxDecoration(color: Colors.red),
    width: 300,
    height: 100,
)),

//Stick out Pattern

ConstrainedBox(
  constraints: BoxConstraints(
  maxWidth: ScreenUtil.getFullWidth(context) * 0.8),
  child: Row(
    children: [
      Container(
        decoration: const BoxDecoration(color: Colors.green),
        width: 300,
        height: 100,
      )
    ])),

image



Solution 1:[1]

do your ConstrainedBox is inside of a ?scaffold widget?

That is sometimes required.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 liam spiegel