0

When I try to add listview, its always gives me errors. Like:

RenderBox was not laid out: RenderRepaintBoundary#dab18 NEEDS-LAYOUT NEEDS-PAINT Failed assertion: line 1982 pos 12 : 'hasSize' The relevant error-causing widget was Column

enter image description here

I tried to add shrinkwrap to listview but it doesn't work too. When I delete my listview its works fine but I need to add it. What am I making wrong? Thanks for all your help! My code :

SliverToBoxAdapter(
              child: Container(
                child: Column(children: [
                  Container( 
                    width: double.infinity,
                    child: Stack(
                      children: [
                        CorneredImage(
                          child: Image(
                            image: AssetImage(
                              'assets/images/phone-call.png',
                            ),
                          ),
                        ),
                        Positioned.fill(
                          child: Container(
                            decoration: //some decors
                          ),
                        ),
                        Positioned.fill(
                          child: Container(
                            alignment: Alignment.topLeft,
                            child: Padding(
                              padding: const EdgeInsets.all(24),
                              child: FractionallySizedBox(
                                widthFactor: 0.7,
                                child: Column(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  mainAxisSize: MainAxisSize.max,
                                  children: [
                                    Flexible(
                                      child: Column(
                                        children: [
                                          Text(
                                            "Dilediğiniz Yerden Bağlanın!", 
                                          ),
                                          SizedBox(height: 10),
                                          Text(
                                            "Terapizone, ihtiyacınız olduğu her an size destek olmak için yanınızda!",
                                           
                                          ),
                                        ],
                                      ),
                                    ),
                                    Align(
                                      alignment: Alignment.bottomLeft,
                                      child: ElevatedButton( 
                                          onPressed: () {},
                                          child: Text("Terapiye Başla"),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                  Flexible( //When I add that part its not working anymore. List is simple String list
                      child: ListView.builder(
                          itemCount: list.length,
                          itemBuilder: (context, index) => Text(list[index]))),
                ]),
              ),
            ),
8
  • 1
    Use Expanded instead of Flexible. Commented Mar 16, 2022 at 11:29
  • @LalitFauzdar thanks for response. But it still have same error brother. Commented Mar 16, 2022 at 11:29
  • 1
    stackoverflow.com/questions/52801201/… check out this Commented Mar 16, 2022 at 11:36
  • 1
    Can you add the shrinkWrap = true parameter and try that? Commented Mar 16, 2022 at 11:45
  • 1
    whats the output you want to achieve? for example why do you use ListView.builder inside SliverToBoxAdapter if you can use SliverList as one child of slivers:? Commented Mar 16, 2022 at 11:50

1 Answer 1

1

Try This,

     CustomScrollView( // Wrap SliverToBoxAdapter with CustomScrollView
              shrinkWrap: true,
              slivers: <Widget>[
                SliverToBoxAdapter(
                  child: Container(
                    child: Column(mainAxisSize: MainAxisSize.min, // give mainAxixsize
                    children: [
                      Container(
                        width: double.infinity,
                        child: Stack(
                          children: [
                            Image(
                              image: AssetImage(
                                'assets/images/phone-call.png',
                              ),
                            ),
                            Positioned.fill(
                              child: Container(
                                alignment: Alignment.topLeft,
                                child: Padding(
                                  padding: const EdgeInsets.all(24),
                                  child: FractionallySizedBox(
                                    widthFactor: 0.7,
                                    child: Column(
                                      mainAxisAlignment: MainAxisAlignment.start,
                                      crossAxisAlignment: CrossAxisAlignment.start,
                                      mainAxisSize: MainAxisSize.max,
                                      children: [
                                        Expanded(
                                          child: Column(
                                            children: [
                                              Text(
                                                "Dilediğiniz Yerden Bağlann!",
                                              ),
                                              SizedBox(height: 10),
                                              Text(
                                                "Terapizone, ihtiyacnz olduğu her an size destek olmak için yannzda!",
                                              ),
                                            ],
                                          ),
                                        ),
                                        Align(
                                            alignment: Alignment.bottomLeft,
                                            child: ElevatedButton(
                                              onPressed: () {},
                                              child: Text("Terapiye Başla"),
                                            ))
                                      ],
                                    ),
                                  ),
                                ),
                              ),
                            )
                          ],
                        ),
                      ),
                 Flexible( //When I add that part its not working anymore. List is simple String list
                  child: ListView.builder(
                      itemCount: list.length,
                      itemBuilder: (context, index) => Text(list[index]))),
                    ]),
                  ),
                ),
                // SizedBox(height: 1) //                           <-- Divider
              ],
            )
Sign up to request clarification or add additional context in comments.

4 Comments

thanks for help brother. But Its already in CustomScrollView. Its like CustomScrollView have 2 sliver now. 1st is sliverappbar second is slivertoboxadapter.
have you added mainAxisSize: MainAxisSize.min ?
I add shrinkwrap=true to my main customscroll view and used Container instead of flexible and gave a height. And insteadof listview builder, I used Listview and its fixed for now thanks man
Great @UgurcanUcar.

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.