简体   繁体   English

我想在 flutter 中创建如下图所示的底部工作表对话框

[英]I want to create bottom sheet dialog like this image below in flutter

Please help me,.请帮我,。 I m new in flutter i want to create like this in my flutter app on button click我是 flutter 的新手,我想在我的 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);
                },
              ),
            )
          ],
        );
      });

Using get plugin使用获取插件

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.

相关问题 我想打开一个活动作为底部工作表对话框 - I want to open an activity as bottom sheet dialog 在我的Android应用程序中,我想像下面的图像一样显示textview吗? - In my android appciation i want to display textview like below image? 我要创建一个从手机屏幕底部打开的对话框(Android Studio),但我不知道它的名称.. 描述中的图像 - I to create like a dialog that opens from the bottom of the screen on phone(Android Studio) but I don't know the name of it.. Image in description 当我点击 Google Map Flutter 上的标记时,我想显示 Modal Bottom Sheet - I want show Modal Bottom Sheet when I click the marker on Google Map Flutter 有没有办法在 android 的底页对话框中创建多 Select 对话框 - Is there a way to create Multi Select Dialog inside a Bottom Sheet Dialog in android 将对话框转换为底部工作表 - Converting Dialog to Bottom Sheet Android的底层表对话框 - Android Bottom Sheet Dialog 如何实现如下图所示的视图? 我想使用 Roatation 从 xml 中创建视图 - How can I achieve the view like below image? I want to make the view from xml using Roatation 我想创建一个像instagram这样的应用程序,但我想用Java代码学习像instagram这样的图像共享应用程序 - i want to create a app like instagram but i want java code for learning image sharing apps like instagram 我想制作具有3D效果的幻灯片菜单,如下图所示 - i want to make slide menu with 3D effect like the below image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM