constraints.hasBoundedHeight': is not true flutter
11,586
Solution 1
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(),
),
Solution 2
So I finally solved the problem of this particular method by doing the following:
- enclosing the
FutureBuilder
in a container; - giving the container width and height;
- adding it to a
ListView
.
Here is the code:
Widget _featuredListHorizontal() {
return Container(
margin: const EdgeInsets.symmetric(vertical: 20.0),
height: 300.0,
child: FutureBuilder(
future: _trendingListImages(),
builder: (BuildContext context, AsyncSnapshot listData) {
if (listData == null) {
return ColorLoader3(
radius: 20.0,
dotRadius: 5.0,
);
} else {
return ListView.builder(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount: listData.data.length,
itemBuilder: (BuildContext context, int position) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Card(
elevation: 18.0,
shape: const RoundedRectangleBorder(
borderRadius:
BorderRadius.all(Radius.circular(10.0))),
clipBehavior: Clip.antiAlias,
margin: const EdgeInsets.all(8.0),
child: Image.network(
"http://image.tmdb.org/t/p/w500/${listData.data[position].backdropPath}",
fit: BoxFit.cover,
height: 200.0,
width: 230.0,
),
),
Text(
listData.data[position].title,
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.bold,
color: Colors.white),
),
],
);
},
);
}
},
),
);
}
Related videos on Youtube
Author by
Emmanuel Okocha
Updated on September 16, 2022Comments
-
Emmanuel Okocha over 1 year
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;}
-
Jeremy Caney over 2 yearsIsn't this basically the same advise as @Conrad's top-voted answer, but with less detail? Conrad wraps a
CustomScrollView
, but it's the same premise.