Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decrease the bottomsheet height dynamically in flutter?

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?

like image 557
Umair Avatar asked Sep 06 '25 03:09

Umair


1 Answers

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(),
              ));
        });
  }
like image 195
Sanjay Sharma Avatar answered Sep 07 '25 21:09

Sanjay Sharma