-1

问题:

当我使用这个小部件时出现溢出错误(下面的代码),我如何解决这个问题?

您可以在下图中看到错误。

在此处输入图像描述

Container(
  height: 150,
  decoration: BoxDecoration(
      color: Colors.red,
      borderRadius: BorderRadius.circular(20),
  ),
  child: Container(
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(20),
            )
)...

你可以在这里查看完整的。

4

3 回答 3

0
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),
                )
    )...
于 2022-01-28T20:36:23.603 回答
0

您的Row小部件对于屏幕来说太大了。您应该更改布局或将代码包装在FittedBoxwiget 中,如下所示:

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>[...],
            ),
          ),
        ),
      )
于 2022-01-28T21:53:01.507 回答
0

尝试使用 Flexible() 包装小部件。在这里阅读更多https://api.flutter.dev/flutter/widgets/Flexible-class.html

于 2022-01-28T20:01:16.567 回答