skip to Main Content

I have 2 listview row widgets inside and I put them inside a SingleChildScrollView so that both have the same scroll. But nothing is visible.

Here is the code:

child: Row(children: [
            SingleChildScrollView(
              child: Row(
                children: [
                  Expanded(
                    child: ListView(
                      physics: NeverScrollableScrollPhysics(),
                      controller: _scrollController2,
                      children: your_history.map((item) {
                        return Column(
                          children: [
                            Container(
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceAround,
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  Column(
                                    children: [
                                      Text("Sizning javobingiz:"),
                                      Text(item)
                                    ],
                                  ),
                                ],
                              ),
                            ),
                            Divider(
                              color: Colors.black,
                            ),
                          ],
                        );
                      }).toList(),
                    ),
                  ),
                  Expanded(
                    child: ListView(
                      physics: NeverScrollableScrollPhysics(),
                      controller: _scrollController,
                      children: true_history.map((item) {
                        return Column(
                          children: [
                            Container(
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceAround,
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  Column(
                                    children: [Text("To'g'ri javob:"), Text(item)],
                                  ),
                                ],
                              ),
                            ),
                            Divider(
                              color: Colors.black,
                            ),
                          ],
                        );
                      }).toList(),
                    ),
                  ),
                ],
              ),
            ),
            
          ]),

SingleChildScrollView ning ichiga joyladim. Ammo hech narsa ko’rinmayabdi.
only String lists are used

the error is as follows:

RenderBox was not laid out: RenderPointerListener#fb2be relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1966 pos 12: 'hasSize'

3

Answers


  1. Remove the first Row and SingleChildScrollView and it will start working.
    You don’t need a SingleChildScrollView to make the list scrollable cause the ListView is scrollable itself.

    Row(
            children: [
              Expanded(
                child: ListView(
                  physics: NeverScrollableScrollPhysics(),
                  controller: _scrollController2,
                  children: your_history.map((item) {
                    return Column(
                      children: [
                        Container(
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceAround,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              Column(
                                children: [
                                  Text("Sizning javobingiz:"),
                                  Text(item)
                                ],
                              ),
                            ],
                          ),
                        ),
                        Divider(
                          color: Colors.black,
                        ),
                      ],
                    );
                  }).toList(),
                ),
              ),
              Expanded(
                child: ListView(
                  physics: NeverScrollableScrollPhysics(),
                  controller: _scrollController,
                  children: true_history.map((item) {
                    return Column(
                      children: [
                        Container(
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceAround,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              Column(
                                children: [Text("To'g'ri javob:"), Text(item)],
                              ),
                            ],
                          ),
                        ),
                        Divider(
                          color: Colors.black,
                        ),
                      ],
                    );
                  }).toList(),
                ),
              ),
            ],
          ),
    
    Login or Signup to reply.
  2. removing singlechildscrollview will work

    Login or Signup to reply.
  3.     List your_history = ['1','2','3','4','1','2','3','4','1','2','3','4','1','2','3','4','1','2','3','4','1','2','3','4'];
        List true_history = ['1','2','3','4'];
        
        return Scaffold(
            body: SingleChildScrollView(
            child: Row(
               mainAxisAlignment: MainAxisAlignment.start,
                                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Expanded(
                        child: ListView(
                          physics: NeverScrollableScrollPhysics(),
                          primary: false,
       shrinkWrap: true,
                          
    //                       controller: _scrollController2,
                          children: your_history.map((item) {
                            return Column(
                              children: [
                                Container(
                                  child:Column(
                                        children: [
                                          Text("Sizning javobingiz:"),
                                          Text(item)
                                        ],
                                      ),
                                ),
                                Divider(
                                  color: Colors.black,
                                ),
                              ],
                            );
                          }).toList(),
                        ),
                      ),
                      Expanded(
                        child: ListView(
                          physics: NeverScrollableScrollPhysics(),
                          primary: false,
       shrinkWrap: true,
    //                       controller: _scrollController,
                          children: true_history.map((item) {
                            return Column(
                              children: [
                                Container(
                                  child: Row(
                                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                                    crossAxisAlignment: CrossAxisAlignment.center,
                                    children: [
                                      Column(
                                        children: [Text("To'g'ri javob:"), Text(item)],
                                      ),
                                    ],
                                  ),
                                ),
                                Divider(
                                  color: Colors.black,
                                ),
                              ],
                            );
                          }).toList(),
                        ),
                      ),
                    ],
                  )),
          );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search