0

This is the likes Widget which shows likes. It is called inside a scrollview column of another dart file. Everything was working fine before this widget's addition

     @override
      Widget build(BuildContext context) {
        return Container(
          height: 100,
          child: Row(
            children: <Widget>[
              Expanded(
                child: ListTile(
                  leading: IconButton(
                    icon: likedByReader
                        ? Icon(Icons.favorite, color: Colors.orange)
                        : Icon(Icons.favorite, color: Colors.grey),
                    onPressed: _pressed,
                  ),
                ),
              ),
              Expanded(
                child: Text('${likesList.length} likes'),
              )
            ],
          ),
        );
      }

This is how LikeWidget is called

Expanded(child: LikeWidget(widget.readerEmail, widget.blogUIDInFirebase),),

Error shown in the console

RenderFlex children have non-zero flex but incoming height constraints are unbounded.

RenderBox was not laid out: _RenderSingleChildViewport#89f28 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'

1 Answers1

1

You can't use Expanded inside a SingleChildScrollView. since the SingleChildScrollView has special constraints and Expanded it's expecting to be used inside a Column or Row . There is a similar question here , and basically you should do conditional rendering for this to work, return a column when the content height is smaller than the parent height, and return a scrollview when the content doesn't fit .For this i would use a LayoutBuilder, but a CustomScrollView seems to be more performant Check the answers of that question.

RegularGuy
  • 3,516
  • 1
  • 12
  • 29