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]))),
                ]),
              ),
            ),
Gwhyyy
  • 7,554
  • 3
  • 8
  • 35
Ugurcan Ucar
  • 289
  • 1
  • 5
  • 23

1 Answers1

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
              ],
            )
Yashraj
  • 1,025
  • 1
  • 5
  • 22