How to decrease the bottomsheet height dynamically in flutter?
993
You can use the following code by replacing PutYourWidgetHere()
with your custom widget.
void showBottomSheet() {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom),
child: PutYourWidgetHere(),
));
});
}
Author by
Umair
Updated on December 01, 2022Comments
-
Umair over 1 year
i am using showModalBottomSheet and given the height of 90% at start. There are two tabs(repeat and onetime) inside bottomsheet, repeat tab has a lot of contents and it is showing perfectly fine with 90% height. But when i tab on onetime tab, i want to decrease the size of bottomsheet to 40% because it does not have more content in it and it does not look nice. But i am unable to change dynamically the height of bottom sheet on pressing onetime tab button.
Can anyone help me how can i achieve this functionality in flutter?
-
Bilaal Abdel Hassan almost 4 yearsUpload your codes so we can understand it better.
-