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

后端 未结 3 1170
青春惊慌失措
青春惊慌失措 2020-12-03 17:36

I am using GridView in my Flutter app to display images and their titles. Please check the below code.

import \'package:flutter/mat         


        
相关标签:
3条回答
  • 2020-12-03 17:58
    Widget build(BuildContext context) {
    
        final _screenSize = MediaQuery.of(context).size;
    
        return Container(
          height: _screenSize.height * 0.2,);
    }                                                                                     
    

    MediaQuery.of(context) It worked for me to use!

    0 讨论(0)
  • 2020-12-03 18:06

    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"),
            )
          ],
        );
      }
    
    0 讨论(0)
  • 2020-12-03 18:08

    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.

    0 讨论(0)
提交回复
热议问题