构造方法
Future<T> showModalBottomSheet<T>({
@required BuildContext context,
@required WidgetBuilder builder,
Color backgroundColor,
double elevation,
ShapeBorder shape, //弹窗shape可以设置圆角
Clip clipBehavior,
Color barrierColor,
bool isScrollControlled = false,
bool useRootNavigator = false,
bool isDismissible = true,//能否点击消失
bool enableDrag = true,//能否拖拽消失
})
使用
_showPopWindow() {
showModalBottomSheet<String>(
context: context,
isDismissible: false,//设置点击弹窗外边是否关闭页面
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(topLeft: Radius.circular(20),topRight: Radius.circular(20)),
),
builder: (BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(30)),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
leading: new Icon(Icons.photo_camera),
title: new Text("Camera"),
onTap: () async {
Navigator.pop(context, 'camera');
},
),
ListTile(
leading: new Icon(Icons.photo_library),
title: new Text("Gallery"),
onTap: () async {
Navigator.pop(context, 'Gallery');
},
),
],
),
);
}).then((value) => print('showModalBottomSheet $value'));
}
网友评论