Flutter: How to fix “A RenderFlex overflowed by pixels ” error?

一笑奈何 提交于 2019-12-01 09:21:28

try to use Expanded instead of Container in _buildImageBoxes() function

  Widget _buildImageBoxes() {
    return Column(
      children: <Widget>[
        Expanded(
          child: Image.network("https://picsum.photos/500/500/?random"),
        ),
        Container(
          padding: EdgeInsets.all(10),
          child: Text("Text"),
        )
      ],
    );
  }

Use fit property in your Image.network method to reduce the size of your image, since they are bigger and overflowing from your container, or you can enlarge your Containers by their height and width properties.

Widget build(BuildContext context) {

final _screenSize = MediaQuery.of(context).size;

return Container(
  height: _screenSize.height * 0.2,

A mi me funciono usar MediaQuery.of(context)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!