Home > Software design >  The behavior when putting Row into ConstrainedBox with Flutter is strange
The behavior when putting Row into ConstrainedBox with Flutter is strange

Time:02-09

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,
      )
    ])),

enter image description here

CodePudding user response:

do your ConstrainedBox is inside of a ‌scaffold widget?

That is sometimes required.

  •  Tags:  
  • Related