'How to wrap height according to child content for showModalBottomSheet or remove auto height

I have one bottom sheet and under that bottom sheet i am managing routing my each screen have different screen size. and i want to change the height of showModalBottomSheet for each screen.

showModalBottomSheet<void>(
      context: context,
      isDismissible: true,
      //isScrollControlled: true,
      elevation: 2.0,
      barrierColor: Colors.white.withOpacity(0),
      builder: (BuildContext context) {
        // double ht = Provider.of<SearchByLocationNotify>(context).getScreenSize;
        return SizedBox(
            height: MediaQuery.of(context).size.height * 0.5,// currently static height provided
            child: PopUpHome());
      },
    );
  1. change the height according to each screen
  2. or wrap the content of children so that static height is not needed

enter image description here

In the above image red porion is showModalBottomSheet blue is my child so i want red portion should only occupy blue.



Solution 1:[1]

return a Column with mainAxisSize: MainAxisSize.min from the builder and place your content inside the Column widget.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Indrajit Sharma