flutter showmodalbottomsheet code example
Example 1: flutter showbottomsheet vs showmodalbottomsheet
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
isScrollControlled: true,
isDismissible: true,
builder: (BuildContext context) {
return DraggableScrollableSheet(
initialChildSize: 0.75, //set this as you want
maxChildSize: 0.75, //set this as you want
minChildSize: 0.75, //set this as you want
expand: true,
builder: (context, scrollController) {
return Container(...); //whatever you're returning, does not have to be a Container
}
);
}
)
Example 2: showModalBottomSheet on load
@override
void initState() {
// TODO: implement initState
Future.delayed(Duration(seconds: 0)).then((_) {
showModalBottomSheet(
context: context,
builder: (builder) {
return Container();
});
});
super.initState();
}