How to Create Bottomsheet With Circular Corners In Flutter??

· 3 min read
How to Create a Modal Bottomsheet With Circular Corners In Flutter
How to Create a Modal Bottomsheet With Circular Corners In Flutter

A bottom sheet is nothing but a material design bottom sheet. so in this article, We will go through How to Create Bottomsheet With Circular Corners In Flutter.

What is Bottomsheet In Flutter?

The bottom sheet is a  material design bottom sheet. There are two kinds of bottom sheets in material design.

  • Persistent:  A persistent bottom sheet shows information that supplements the primary content of the app.
  • Modal: A modal bottom sheet is an alternative to a menu or a dialog and prevents the user from interacting with the rest of the app.

How to Create Bottomsheet With Circular Corners In Flutter?

You can now do it using the default showModalBottomSheet method that now supports adding a ShapeBorder and also backgroundColor!

showModalBottomSheet(
  shape: RoundedRectangleBorder(
     borderRadius: BorderRadius.circular(10.0),
  ),
  backgroundColor: Colors.white,
  ...
);

I think the best way to do a rounded-corner modal is to use a RoundedRectangleBorder with a vertical BorderRadius, setting only its top property:

showModalBottomSheet(
        context: context,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.vertical(top: Radius.circular(25.0)),
        ),
        builder: (BuildContext context) {
          // return your layout
        });

You can now simply set the shape argument. Example:

showModalBottomSheet(
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.all(Radius.circular(10.0)),
  ),
  context: context,
  builder: (context) => MyBottomSheet(),
);

You can also try the below way.

showModalBottomSheet(
        context: context,
        backgroundColor: Colors.white,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.only(topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0)),
        ),
        builder: (context) {
          return Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[     
              ListTile(
                leading: Icon(Icons.email),
                title: Text('Send email'),
                onTap: () {
                  print('Send email');
                },
              ),
              ListTile(
                leading: Icon(Icons.phone),
                title: Text('Call phone'),
                 onTap: () {
                    print('Call phone');
                  },
               ),                  
            ],
          );
        });

Conclusion:

So in this article, We have been through How to Change ListTile Background Color On Selection.

Keep Learning !!! Keep Fluttering !!!

Still, need Support for Flutter Development? Do let us know.

FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

FlutterAgency.com is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

Leave a Reply