组件_AlertDialog

2018-08-03  本文已影响15人  _白羊

定义:一个会中断用户操作的对话框,需要用户确认

属性 解释
title 对话框标题
titlePadding 对话框标题内边距
titlePadding 对话框标题内边距
content 对话框的(可选)内容以较轻的字体显示在对话框的中心
contentPadding 内容的内边距
actions 在对话框底部显示的(可选的)操作集合
semanticLabel 语义标签

示例:

...
       child: FlatButton(
          color: Colors.blue,
          onPressed: () {
            showDialog(
              context: context,
              builder: (BuildContext context) {
                return AlertDialog(
                  // 对话框的(可选)标题显示在对话框顶部
                  title: new Text('对话框的标题'),   

                  // 对话框标题内边距
                  titlePadding: EdgeInsets.all(20.0), 

                  // 对话框的(可选)内容以较轻的字体显示在对话框的中心
                  content: new Text('内容部分'), 
                  
                  // 内容的内边距
                  contentPadding: EdgeInsets.all(20.0), 

                  // 在对话框底部显示的(可选的)操作集合
                  actions: <Widget>[
                    FlatButton(
                      onPressed: () {
                        Navigator.pop(context);
                      },
                      child: new Text('确认'),
                    ),
                    FlatButton(
                      onPressed: () {
                        Navigator.pop(context);
                      },
                      child: new Text('取消'),
                    ),
                  ],

                  // 语义标签
                  semanticLabel: '语义标签', 
                );
              },
            );
          },
          child: new Text('点击'),
        ),
...

效果:


image.png
上一篇 下一篇

猜你喜欢

热点阅读