Flutter中如何实现自定义对话框? [英] How to implement a Custom dialog box in flutter?
本文介绍了Flutter中如何实现自定义对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 Flutter 新手,需要创建一个图库应用,该应用需要自定义对话框来显示所选图像.我该如何实现?
I'm new to flutter and need to create a gallery app that needs a custom dialog box to show the selected image. How can I implement that?
推荐答案
使用 Dialog 类,它是 Flutter 中 AlertDialog 类的父类.对话框小部件有一个参数shape".您可以使用它来塑造对话框的边缘.
Use Dialog class which is a parent class to AlertDialog class in Flutter. Dialog widget has a argument , "shape" which you can use to shape the Edges of the Dialog box.
这是一个代码示例:
Dialog errorDialog = Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), //this right here
child: Container(
height: 300.0,
width: 300.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.all(15.0),
child: Text('Cool', style: TextStyle(color: Colors.red),),
),
Padding(
padding: EdgeInsets.all(15.0),
child: Text('Awesome', style: TextStyle(color: Colors.red),),
),
Padding(padding: EdgeInsets.only(top: 50.0)),
TextButton(onPressed: () {
Navigator.of(context).pop();
},
child: Text('Got It!', style: TextStyle(color: Colors.purple, fontSize: 18.0),))
],
),
),
);
showDialog(context: context, builder: (BuildContext context) => errorDialog);}
这篇关于Flutter中如何实现自定义对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文