Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

constraints.hasBoundedHeight': is not true flutter

Tags:

flutter

dart

I am stacking widgets and i want it to be scrollable so i used a listview and i am getting this error (constraints.hasBoundedHeight': is not true flutter) i saw somewhere that listview cannot be placed inside a listview so i changed it to Column but i still got the same error. Below is my Code. Thanks.

ListView homeList(){
var listView = ListView(
  shrinkWrap: true,
  children: <Widget>[
    _imageSlider(),

    Padding(
      padding: EdgeInsets.only(top: 15.0, bottom: 15.0, left: 15.0),
      child: Text("Trending", style: TextStyle(color: Colors.white, fontSize: 15.0),),
    ),

   Container(
     child: FutureBuilder(
       future: _trendingListImages(),
         builder: (BuildContext context, AsyncSnapshot async){
           if(async.data == null){
           return ColorLoader3(
          radius: 20.0,
          dotRadius: 5.0,
           );
          }else{
            return ListView.builder(
                shrinkWrap: true,
                scrollDirection: Axis.horizontal,
                itemCount: async.data.length,
                itemBuilder: (BuildContext context, int position) {
                  return Column(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      Card(
                        elevation: 18.0,
                        shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.all(Radius.circular(10.0))),
                        child: Image.network(
                          "http://image.tmdb.org/t/p/w500/"+async.data[position].backdropPath,
                          fit: BoxFit.cover,
                          height: 200.0,
                          width: 130.0,
                        ),
                        clipBehavior: Clip.antiAlias,
                        margin: EdgeInsets.all(8.0),
                      ),
                      Text(
                        async.data[position].title,
                        style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
                      )
                    ],
                  );
                });
           }
         }
     ),
   )
  ],
);

return listView;}
like image 830
Emmanuel Okocha Avatar asked Feb 19 '19 19:02

Emmanuel Okocha


1 Answers

For me worked just wrapping the CustomScrollView or ListView with a Container. Like this:

 Container(
                margin: EdgeInsets.all(5.0),
                height: 295.0,
                width: 333.0,
                child: CustomScrollView(),
              ),
like image 197
Conrad Mota Avatar answered Sep 20 '22 22:09

Conrad Mota