Reputation: 45
Is there a way to work out the complete height of a SingleChildScrollView so it can be used setting the ConstrainedBox height. I have a SingleChildScrollView which contains a number of widgets including columns and an Expanded which can vary in height. I have tried a number of different techniques including using MediaQuery.of(context).size.height but this only provides a height of the visible screen, not the total height of the not total scrollable area.
child: SingleChildScrollView( controller: scrollController, child: ConstrainedBox( constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height+MediaQuery.of(context).size.height),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ConstrainedBox(
constraints: BoxConstraints(maxHeight: 295, minHeight: 100.0),
child: PageView.builder(
itemCount: videObj.results.length,
controller: PageController(viewportFraction: 0.8, initialPage: 1),
itemBuilder: (_, i) {
String vidKey = videObj.results[i].key;
String thumbPath = 'https://image.api.playstation.com/vulcan/img/cfn/11307uYG0CXzRuA9aryByTHYrQLFz-HVQ3VVl7aAysxK15HMpqjkAIcC_R5vdfZt52hAXQNHoYhSuoSq_46_MT_tDBcLu49I.png';
ListView.builder(
padding: const EdgeInsets.all(8),
itemCount: listseasons.length,
itemBuilder: (BuildContext context, int index) {
return Text(listseasons[index].name);
});
return Transform.scale(
scale: i == _index ? 1 : 1,
child: new InkWell(
onTap: () {
launch(videoPath);
},
child: Card(
clipBehavior: Clip.antiAlias,
child: Column(
children: [
Image.network(thumbPath,
fit: BoxFit.cover,
),
ListTile(
title: Text(videObj.results[i].name),
),
],
)
),
),
);
},
),
Upvotes: 0
Views: 395
Reputation: 539
I try to answer but imo lot of missing pieces in your code. You can get widget height using keys.
GlobalKey globalKey = GlobalKey();
Then pass it to child example:
Container(key: globalKey, ... rest of the stuff)
And then in your code you can use:
globalKey.currentContext.size.height
Upvotes: 0