Flutter开发之——SimpleDialog

一 概述

  • SimpleDialog的用法跟AlertDialog基本类似
  • SimpleDialog跟showDialog联合使用

二 SimpleDialog

2.1 构造方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const SimpleDialog({
Key? key,
this.title,
this.titlePadding = const EdgeInsets.fromLTRB(24.0, 24.0, 24.0, 0.0),
this.titleTextStyle,
this.children,
this.contentPadding = const EdgeInsets.fromLTRB(0.0, 12.0, 0.0, 16.0),
this.backgroundColor,
this.elevation,
this.semanticLabel,
this.insetPadding = _defaultInsetPadding,
this.clipBehavior = Clip.none,
this.shape,
})

三 示例

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
RaisedButton(
child: Text("SimpleDialog"),
onPressed: () {
showDialog(
context: context,
builder: (builder) {
return SimpleDialog(
title: Text('提示'),
children: <Widget>[
Container(height: 80, alignment: Alignment.center, child: Text('确认删除吗?'),),
Divider(height: 1,),
FlatButton(child: Text('取消'), onPressed: () {Navigator.of(context).pop('cancel');},),
Divider(height: 1,),
FlatButton(child: Text('确认'), onPressed: () {Navigator.of(context).pop('ok');},
),
],
);
});
})

效果图