AlertDialog:创建一个警告对话框。
_AlertDialog() async {
var alertRel = await showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text("提示!"),
content: Text("确定要删除吗"),
actions: <Widget>[
FlatButton(
child: Text("取消"),
onPressed: () {
Navigator.pop(context, 'Cancle');
},
),
FlatButton(
child: Text("确定"),
onPressed: () {
Navigator.pop(context, 'Ok');
},
)
],
);
}
);
}
SimpleDialog:创建一个简单的对话框。
_SimpleDialog() async {
var simpleRel = await showDialog(
context: context,
builder: (BuildContext context) {
return SimpleDialog(
title: Text("select 单选按钮框"),
children: <Widget>[
SimpleDialogOption(
child: Text("Option A"),
onPressed: () {
Navigator.pop(context, 'Option A');
},
),
Divider(),
SimpleDialogOption(
child: Text("Option B"),
onPressed: () {
Navigator.pop(context, 'Option B');
},
),
Divider(),
SimpleDialogOption(
child: Text("Option C"),
onPressed: () {
Navigator.pop(context, 'Option C');
},
)
],
);
}
);
}
showModalBottomSheet:创建一个底部页面。
_showModalBottomSheet() async {
var actionSheet = await showModalBottomSheet(
context: context,
builder: (builder) {
return Container(
height: 200,
child: Column(
children: <Widget>[
ListTile(
title: Text("分享 A"),
onTap: () {
Navigator.pop(context, 'A');
},
),
ListTile(
title: Text("分享 B"),
onTap: () {
Navigator.pop(context, 'B');
},
),
ListTile(
title: Text("分享 C"),
onTap: () {
Navigator.pop(context, 'C');
},
)
],
),
);
}
);
}
showToast:调用将显示消息的平台的 showToast
pub地址:https://pub.dev/packages/fluttertoast
_showToast() {
Fluttertoast.showToast(
msg: "This is Short Toast",
toastLength: Toast.LENGTH_SHORT,
timeInSecForIosWeb: 1);
}
THE END