0

This is my current code:

Widget _buildListItem(BuildContext context, DocumentSnapshot data) {
    final record3 = Record3.fromSnapshot(data);

    int iconCode = record3.ref;

    List<IconData> _iconsDaily = [
      Icons.shopping_cart,
      Icons.cake_rounded,
      Icons.card_giftcard,
      Icons.control_point,
    ];

    return Padding(
      key: ValueKey(record3.name),
      padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),

      child: new Container(
        child: new ListView(
          children: <Widget>[
            new Text(
              "Daily Goals",
            ),
            new Container(
              child: new ListView(
                scrollDirection: Axis.horizontal,
                children: new List.generate(4, (int index) {
                  return new Positioned(
                    child: new DailyButton(
                        onTap: () {
                          if (_iconsDaily[index] == Icons.control_point) {
                            showDialog(
                              context: context,
                              builder: (BuildContext context) =>
                                  _buildPopupDialog(context),
                            );
                          }
                        },
                        iconData: _iconsDaily[index]),
                  );
                }),
              ),
            ),
          ],
        ),
      ),

For some reason, it is not showing anything on the app and is throwing a lot of errors such as:

flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#c5f6b relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#72b6b relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#37263 relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

If I remove the ListView and <Widget> then it works fine:

return Padding(
      key: ValueKey(record3.name),
      child: new Container(
              child: new ListView(
                scrollDirection: Axis.horizontal,
                children: new List.generate(4, (int index) {
                  return new Positioned(
                    child: new DailyButton(
                        onTap: () {
                          if (_iconsDaily[index] == Icons.control_point) {
                            showDialog(
                              context: context,
                              builder: (BuildContext context) =>
                                  _buildPopupDialog(context),
                            );
                          }
                        },
                        iconData: _iconsDaily[index]),
                  );
                }),
              ),
            ),

However, I don't want to remove these as I am not too sure how I to then add more features like Text and Container. Any help would be appreciated!

ajnabz
  • 297
  • 5
  • 25
  • The problem is because the Horizontal ListView https://stackoverflow.com/questions/54668966/horizontal-listview-flutter-without-explicit-height/63399900?noredirect=1#comment116661451_63399900 – John Joe Feb 01 '21 at 15:51
  • @JohnJoe Thank you so much, I added ```height: 100.0``` after the first container and it is now displaying. Thank you! – ajnabz Feb 01 '21 at 15:56
  • no problem..... – John Joe Feb 01 '21 at 16:07

0 Answers0