gpt4 book ai didi

flutter - 无法增加 flutter 中对话框的宽度

转载 作者:IT王子 更新时间:2023-10-29 06:45:25 25 4
gpt4 key购买 nike

我需要在我的应用程序中构建一个弹出对话框。我正在使用 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"),
),
]
),
),
),
),
);
},

最佳答案

试试这个

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"),
),
],
),
),
);
},
);

我用 builder 替换了 child 参数,因为 child 已被弃用。

它在屏幕边界之外有边距,因此它不能覆盖整个屏幕,但可以覆盖到一个限制。

关于flutter - 无法增加 flutter 中对话框的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55277499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com