Jut*_*Aka 6 flutter flutter-layout
我需要在我的应用程序中构建一个弹出对话框。我正在使用 Dialog 类并用 SizedBox 类包装它以增加对话框的宽度。但是,对话框的宽度并没有增加。我怎样才能增加它的宽度?
onTap: () {
showDialog(
context: context,
child:SizedBox(
width: 900,
child: Dialog(
backgroundColor :Colors.white,
insetAnimationDuration: const Duration(milliseconds: 10),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
child: Container(
child: Column(
children: <Widget>[
Text('hello'),
FlatButton(
onPressed: () {
Navigator.of(context).pop();
},
child: new Text("OK"),
),
]
),
),
),
),
);
},Run Code Online (Sandbox Code Playgroud)
尝试这个
`showDialog(
context: context,
builder: (context) {
return Dialog(
backgroundColor: Colors.white,
insetAnimationDuration:
const Duration(milliseconds: 100),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20)),
child: Container( // use container to change width and height
height: 200,
width: 400,
child: Column(
children: <Widget>[
Text('hello'),
FlatButton(
onPressed: () {
Navigator.of(context).pop();
},
child: new Text("OK"),
),
],
),
),
);
},
);`
Run Code Online (Sandbox Code Playgroud)
在这里,我用 builder 替换了 showDialog 的子参数,因为它已被弃用,并且使用 dailogs ,它与屏幕边界相距。因此,如果您希望 dailog 适合整个屏幕,则不能但是如果更宽的屏幕或横向,则宽度可以更改为限制
| 归档时间: |
|
| 查看次数: |
6541 次 |
| 最近记录: |