Problem:
I have an overflow error when i use this widget (code below), How i solve the issue?
You can see the error in the image below.
Container(
height: 150,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(20),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
)
)...
You can check the complete here.
CodePudding user response:
Try wrapping the widget with Flexible(). Read more here https://api.flutter.dev/flutter/widgets/Flexible-class.html
CodePudding user response:
The child Container should have defined height, try giving it a given height, and the height must not be greater than the parent height. - Increase the height of the parent container and also give the child Container a height and width
.
Container(
height: 300,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(20),
),
child: Container(
height:'your height',
width:'your width',
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
)
)...
CodePudding user response:
your Row widget is too big for screen. you should change your layout or wrap you code in FittedBox wiget like this:
Container(
height: 150,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(20),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
),
child: FittedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[...],
),
),
),
)
