when the bottom sheet appears it does not has that much height. but when a checkbox clicked in the bottom sheet it is expanding to the top regardless the screen size. what I have been trying to do is to set max height for bottom sheet. can't find proper solution for that so far. any helps are welcome!
CodePudding user response:
For the bottom sheet, you need to set the height of the sheet.
and before you set the height set to enable this option
isScrollControlled: true,
height: MediaQuery.of(context).size.height - 100,
CodePudding user response:
Set showModalBottomSheet isScrollControlled
property to true
, then set the child Container height
property to double.infinity
showModalBottomSheet<void>(
isScrollControlled: true, //this
context: context,
builder: (BuildContext context) {
return Container(
height: double.infinity, //this
color: Colors.amber,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('Modal BottomSheet'),
ElevatedButton(
child: const Text('Close BottomSheet'),
onPressed: () => Navigator.pop(context),
),
],
),
),
);
},
);