20

I have created a screen with multiple widgets in a single column. I got the error. And then I have updated the height for the containers in the columns then the screen is not scrolled as it has some fixed size.

Then I moved from columns to ListView but still, my widgets do not scroll.

  new ListView(
          shrinkWrap: true,
          children: <Widget>[

            // Author information
            new Container(
              height: MediaQuery
                  .of(context)
                  .size
                  .height * .075,
              width: double.infinity,
              padding: const EdgeInsets.only(
                  top: 10.00, right: 10.00),
              child: new Row(

                children: <Widget>[

                  new CircleAvatar(

                    backgroundColor: new Color(0xFF535386),
                    foregroundColor: new Color(0xFFF4F4F4),
                    backgroundImage: new NetworkImage(
                        _feed.authorImageUrl),
                    radius: 30.00,
                    child: new Text(
                        _feed.authorName.substring(0, 1)
                            .toUpperCase()),
                  ),

                  new Padding(padding: EdgeInsets.only(
                      bottom: 5.00, top: 2.00, left: 5.00),
                      child: new Column(
                        crossAxisAlignment: CrossAxisAlignment
                            .start,
                        children: <Widget>[
                          new Text(
                            _feed.authorName,
                            textAlign: TextAlign.start,
                            softWrap: true,
                            style: new TextStyle(
                              fontSize: 20.0,

                            ),
                          ),
                          new Text(_feed.dateTime,
                            textAlign: TextAlign.start,),
                        ],
                      )),

                ],

              ),
            ),

            // Title

            new Padding(padding: const EdgeInsets.only(
                top: 10.00, left: 10.00),
              child: new Text(
                _feed.title, textAlign: TextAlign.start,),
            ),

            // content

            new Container(
              child: new Text(
                _feed.content, textAlign: TextAlign.start,),
            ),
          ],
        ),
5
  • Use a docs.flutter.io/flutter/widgets/ListView-class.html Commented Jul 30, 2018 at 8:44
  • @GünterZöchbauer I used ListView also it not working. Please check the above code. Commented Jul 30, 2018 at 8:48
  • Is the content higher than the list? Try enabling flutter.io/debugging/#visual-debugging debugPaintSizeEnabled=true; Commented Jul 30, 2018 at 8:55
  • Yes, I am loading the complete forum feed in this Text() so for some feeds the content is higher. This forum application. The complete forum post and its comments will be loaded on this screen. That's why I am looking scroll. Commented Jul 30, 2018 at 8:58
  • I think the MediaQuery is causing your problem. What effect are you trying to achieve? Using Expanded might be a better way to achieve a proportional layout if that's what your after. Commented Jul 30, 2018 at 9:34

1 Answer 1

44

Your ListView seems to be fine, but I'm guessing it's wrapped inside a fixed size Widget as Column or Row (the yellow and black error means that the content is bigger than the available space), so you should wrap the ListView inside an Expanded widget like this:

new Expanded(
    child: new ListView(
      shrinkWrap: true,
      children: <Widget>[
        //Your content
      ],
    )
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.