类似于dropDownMenuButton的弹出效果

时间:2019-07-24 12:27:40

标签: flutter flutter-layout

我希望我可以使这种弹出效果类似于dropDownMenuButton。是否有任何插件或示例可用于参考或帮助?

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

如果您想要一个浮动窗口,我建议使用对话框。

要使用对话框,请使用函数并为其提供上下文

此示例应显示带有“ YAY!”的圆形的白色对话框。在它的中间。

关闭调用Navigator.of(context).pop()的对话框,还可以将align小部件与padding结合使用,使其显示在底部,顶部,左侧和右侧。

触摸对话框的背景也会将其关闭。

void _showDialog(context) {
    showDialog(
      context: context,
      builder: (BuildContext context) {
        // return my custom widgets
        return Center(
            child: SizedBox(
                width: 250.0,
                height: 250.0,
                child: Material( //Use material to use FlatButton, IconButton, InkWell, etc.
                    borderRadius: BorderRadius.all(Radius.circular(12.0)),
                    color: Colors.white,
                    child: Text('YAY!')
                    )));
      },
    );
  }

随时尝试。