showModalBottomSheet does not provide any styling or decorations. I want to create something like the Google Tasks bottomsheet.
Putting together all the answers before, I could achieve the best result possible (in my opinion) for this.
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');
},
),
],
);
});
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
});
Using separate radii for top left and top right is a bit more verbose and error-prone.
You can now simply set the shape
argument.
Example:
showModalBottomSheet(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
),
context: context,
builder: (context) => MyBottomSheet(),
);