[英]I want to create bottom sheet dialog like this image below in flutter
Try below code,试试下面的代码,
showModalBottomSheet(
context: context,
builder: (BuildContext cntx) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
leading: Icon(Icons.camera),
title: Text("Camera"),
onTap: () async {
},
),
ListTile(
leading: Icon(Icons.image),
title: Text("Files")),
onTap: () async {
},
),
Container(
height: 50,
color: prefix0.appBackgroundColcor,
child: ListTile(
title: Center(
child: Text(
"Cancel",
style: TextStyle(color: Colors.white),
),
),
onTap: () {
Navigator.pop(context);
},
),
)
],
);
});
GestureDetector(
onTap: () {
Get.bottomSheet(
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 200,
color: Colors.transparent,
child:Column(
children: [
Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.greenAccent
),
child: Padding(
padding: const EdgeInsets.all(18),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Use Camera', style: TextStyle(fontSize: 16),),
SizedBox(height: 20,),
Text('Upload from File', style: TextStyle(fontSize: 16),),
SizedBox(height: 20,),
Text('Upload from Dropbox', style: TextStyle(fontSize: 16),),
],
),
)
),
SizedBox(height: 10,),
Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.greenAccent
),
child: Padding(
padding: const EdgeInsets.all(15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Cancel', style: TextStyle(fontSize: 16, color: Colors.red),),
],
),
)
),
],
)
),
),
isDismissible: true,
enableDrag: false,
);
},
child: Container(
width: 100,
height: 50,
child: Text('Open Bottom Sheet')
),
),
You can use cupertino bottom modal to achieve something like that.您可以使用 cupertino 底部模态来实现类似的效果。 See below code for implementation:
请参阅下面的代码以实现:
void show() {
showCupertinoModalPopup(
context: context,
builder: (BuildContext cont) {
return CupertinoActionSheet(
actions: [
CupertinoActionSheetAction(
onPressed: () {
print('Camera');
},
child: Text('Use Camera'),
),
CupertinoActionSheetAction(
onPressed: () {
print('Upload files');
},
child: Text('Upload from files'),
),
CupertinoActionSheetAction(
onPressed: () {
print('Dropbox');
},
child: Text('Upload from DropBox'),
)
],
cancelButton: CupertinoActionSheetAction(
onPressed: () {
Navigator.of(cont).pop;
},
child: Text('Cancel', style: TextStyle(color: Colors.red)),
),
);
});
}
Call the show function with the press of any button.按下任意按钮即可调用节目 function。 You will see something like this.
你会看到这样的东西。
If you don't want the divider between actions you have to create your own custom popup.如果您不想要操作之间的分隔符,则必须创建自己的自定义弹出窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.