flutterios

Flutter之AlertDialog组件

2019-03-20  本文已影响0人  习惯了_就好
/**
 * 提示对话框,显示提示内容和操作按钮
 * const AlertDialog({
    Key key,
    this.title,//标题
    this.titlePadding,//标题间距
    this.content,//要显示的内容项
    this.contentPadding = const EdgeInsets.fromLTRB(24.0, 20.0, 24.0, 24.0),//内容间距
    this.actions,//底部按钮
    this.semanticLabel,//
    this.shape,//
    })
 */
body: RaisedButton(
          onPressed: () {
            showDialog(
                context: context,
                builder: (BuildContext context) {
                  return AlertDialog(
                    title: Text("这是标题"),
                    titlePadding: EdgeInsets.only(bottom: 30.0, left: 10.0),
                    content: SingleChildScrollView(
                      child: ListBody(
                        children: <Widget>[
                          Text("这是第一行"),
                          Text("这是第二行"),
                          Text("这是第三行"),
                        ],
                      ),
                    ),
                    contentPadding: EdgeInsets.only(left: 40.0),
                    actions: <Widget>[
                      FlatButton(
                          onPressed: () {},
                          child: Text("取消")
                      ),
                      RaisedButton(
                        onPressed: () {},
                        child: Text(
                          "确定",
                          style: TextStyle(color: Colors.white),
                        ),
                      ),

                    ],
                  );
                }
            );
          },
          child: Text("点击显示AlertDialog"),
        ),
上一篇 下一篇

猜你喜欢

热点阅读