Flutter SimpleDialog 对话框

知识共享许可协议 版权声明:署名,允许他人基于本文进行创作,且必须基于与原先许可协议相同的许可协议分发本文 (Creative Commons

简单的对话框为用户提供了多个选项之间的选择。一个简单的对话框有一个可选的标题,显示在选项上方。 

参数详解

属性 说明
title 标题
titlePadding 标题内边距 默认EdgeInsets.fromLTRB(24.0, 24.0, 24.0, 0.0),
children 子组件集合
contentPadding 内容内边距 EdgeInsets.fromLTRB(0.0, 12.0, 0.0, 16.0),
backgroundColor 背景颜色
elevation 阴阳高度
semanticLabel  
shape 形状

代码示例

return SimpleDialog(
          title: const Text('请选择你的性别'),
          children: <Widget>[
            SimpleDialogOption(
              onPressed: () {
                Navigator.pop(context);
              },
              child: const Text('我是男人'),
            ),
            SimpleDialogOption(
              onPressed: () {
                Navigator.pop(context);
              },
              child: const Text('我是女人'),
            ),
            SimpleDialogOption(
              onPressed: () {
                Navigator.pop(context);
              },
              child: const Text('我是人妖'),
            ),
          ],
        );

效果图

完整代码

查看完整代码

猜你喜欢

转载自blog.csdn.net/ruoshui_t/article/details/94331236