Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter bottom sheet corner radius

I am writing an app that needs to have a bottomsheet with corner radius. Something like you can see in the Google Task app.

Here is the code I have

showModalBottomSheet(
        context: context,
        builder: (builder) {
          return new Container(
            height: 350.0,
            color: Colors.transparent,
            child: new Container(
                decoration: new BoxDecoration(
                    color: Colors.white,
                    borderRadius: new BorderRadius.only(
                        topLeft: const Radius.circular(10.0), topRight: const Radius.circular(10.0))),
                child: new Center(
                  child: new Text("This is a modal sheet"),
                )),
          );
        });

Is still shows the sheet without the border radius. enter image description here

Okay, I found a reason. It is indeed displaying the rounded corner but the background of the Container is staying white due to Scaffold background color. Now the question is how do I override the Scaffold background color.

like image 749
hvkale Avatar asked Mar 13 '26 06:03

hvkale


1 Answers

For those who still trying to resolve this:

for some reasons Colors.transparent does not work, so all you need to do is change color to : Color(0xFF737373)

showModalBottomSheet(
        context: context,
        builder: (builder) {
          return new Container(
            height: 350.0,
            color: Color(0xFF737373),
            child: new Container(
                decoration: new BoxDecoration(
                    color: Colors.white,
                    borderRadius: new BorderRadius.only(
                        topLeft: const Radius.circular(10.0), topRight: const Radius.circular(10.0))),
                child: new Center(
                  child: new Text("This is a modal sheet"),
                )),
          );
        });
like image 65
pa. Avatar answered Mar 15 '26 21:03

pa.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!