Vertical viewport was given unbounded height. RenderBox was not laid out: RenderViewport#34d12 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

Viewed 282

I can't list my data with listview.builder.

Viewports expand in the scrolling direction to fill their container. In this case, a vertical viewport was given an unlimited amount of vertical space in which to expand. This situation typically happens when a scrollable widget is nested inside another scrollable widget. If this widget is always nested in a scrollable widget there is no need to use a viewport because there will always be enough vertical space for the children. In this case, consider using a Column instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size the height of the viewport to the sum of the heights of its children.

How can I use listview.builder in listview?

import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hexcolor/hexcolor.dart';
class Profil extends StatefulWidget {
  @override
  _ProfilState createState() => _ProfilState();
}
class _ProfilState extends State<Profil> {
  final List<String> entries = <String>['Privacy', 'Purshase History', 'Help & Support','Settings','Invite a Friend'];
  final  List<Icon> iconsImage =
  [Icon(Icons.privacy_tip),
    Icon(Icons.history),
    Icon(Icons.help),
    Icon(Icons.settings),
  Icon(Icons.person_add_alt)
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title:Text("Profilim",style: TextStyle(fontSize: 20),),backgroundColor: HexColor("#0e2d85"),actions: [
        Container(padding: EdgeInsets.only(right: 15),child: Icon(Icons.exit_to_app)),
      ],),
      body: Container(
        child: Padding(
          padding: const EdgeInsets.only(top:10.0,right: 10),
          child: Column(
            children: [
              Column(children: [
                Row( mainAxisAlignment:MainAxisAlignment.end,children:[IconButton(icon: Icon(FontAwesomeIcons.highlighter), onPressed: (){})] ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 12),
                  child: Row(
                    children: [
                      Stack(children: [
                        Container(
                          height: 150,
                          width: 150,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(80),
                            image: DecorationImage(image: AssetImage("assets/BG.jpg"),fit: BoxFit.cover),
                          ),
                        ),
                              Positioned(
                                  top: 125,
                                  left: 120,
                                  child: Container(
                                    child: CircleAvatar(
                                      child: Icon(
                                        Icons.edit,
                                        color: Colors.yellow,
                                        size: 15,
                                      ),
                                    ),
                                  )),
                      ],
                      ),
                      SizedBox(width: 30,),
                      Column(
                        children: [
                          Text("Salih"),
                          SizedBox(height: 10,),
                          Text("salih@gmail.com"),
                          SizedBox(height: 10,),
                          Container(width:200,child: RaisedButton(onPressed: (){}, color:Colors.yellow[200],child: Text("Upgrade to PRO",style: TextStyle(color: Colors.black),),shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),))
                        ],
                      )
                    ],
                  ),
                )
              ],
              ),
        ListView.builder(
            padding: const EdgeInsets.all(8),
            itemCount: 2,
            itemBuilder: (BuildContext context, int index) {
              return Container(
                height: 20,
                child: Center(child: Text('Entry ${entries[index]}')),
              );
            }
        ),
            ],
          ),
        ),
      )
    );
  }
}
1 Answers

you can wrap your Listview.builder in Expanded widget to let listview take the space that is left after the above content of Column. But again it will only take the height that is left on page after the above content of Column and will scroll in that space only!

Related