Reputation: 763
I want how to make dynamic or auto height value in a flutter
I have listview and container which contain listview.
but if the height of the container is less than the total height of listview the result doesn't be shown in screen.
so if listview's length or height becomes higher Container's height becomes higher this is what I want
how can I?
Container(
height: 400,
//auto height need
child: ListView.builder(
padding: EdgeInsets.only(top: 5), //gab betwween horizonscroll
physics: NeverScrollableScrollPhysics(), //listview scroll fix
itemCount: weatherList.length,
itemBuilder: (context, i) {
return SizedBox(
height: 60,
child: Card(
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Text(weatherList[i].weekName),
),
Column(
children: <Widget>[
weatherList[i].weekIcon,
Text(weatherList[i].weekTemper),
],
),
Padding(
padding: const EdgeInsets.only(right: 10.0),
child: Text(weatherList[i].weekdust),
),
],
)),
);
},
),
);
Upvotes: 3
Views: 4121
Reputation: 2673
You can try using MediaQuery
MediaQuery class Establishes a subtree in which media queries resolve to the given data.
For example, to learn the size of the current media (e.g., the window containing your app), you can read the MediaQueryData.size
property from the MediaQueryData
returned by MediaQuery.of
: MediaQuery.of(context).size
.
Upvotes: 0