-
Flutter Dialog
(1)AboutDialog
(2)AlertDialog
(3)SimpleDialog
// AboutDialog
void showAboutDialog(BuildContext context) {
showDialog(context: context, builder: (_) => new AboutDialog(
applicationName: 'AndroidStudio',
applicationIcon: Icon(Icons.add_chart),
children: [
Text('这是一个AndroidStudio')
],
));
}
// SimpleDialog
void showSimpleDialog(BuildContext context) {
showDialog(context: context, builder: (_) => new SimpleDialog(
title: Text('选择'),
children: [
SimpleDialogOption(
child: Text('选项1'),
onPressed: () {
Navigator.of(context).pop();
},
),
SimpleDialogOption(
child: Text('选项2'),
onPressed: () {
Navigator.of(context).pop();
},
),
SimpleDialogOption(
child: Text('选项3'),
onPressed: () {
Navigator.of(context).pop();
},
),
SimpleDialogOption(
child: Text('选项4'),
onPressed: () {
Navigator.of(context).pop();
},
)
],
));
}
// AlertDialog
void showAlertDialog(BuildContext context) {
showDialog(context: context, builder: (_) => new AlertDialog(
title: Text('标题'),
content: SingleChildScrollView(
child: ListBody(
children: [
Text('较长的List。。。'),
Text('较长的List。。。'),
Text('较长的List。。。'),
Text('较长的List。。。'),
Text('较长的List。。。'),
Text('较长的List。。。'),
Text('较长的List。。。'),
Text('较长的List。。。'),
Text('较长的List。。。'),
],
),
),
actions: [
FlatButton(onPressed: () {
Navigator.of(context).pop();
}, child: Text('确定')),
FlatButton(onPressed: () {
Navigator.of(context).pop();
}, child: Text('取消')),
],
));
}