Flutter & AlertDialog:如何拉伸容器使其与 AlertDialog 框具有相同的宽度?
Flutter & AlertDialog : How to stretch a container so that it has the same width with the AlertDialog box?
我一直在尝试在 Flutter 的 AlertDialog
框中制作一个按钮。但是我找不到拉伸按钮容器的方法。请检查我的代码并查看下面的示例图片。
AlertDialog(
title: Center(child: Text("Picture")),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: width,
//height: height,
child: FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: image.url,
),
),
SizedBox(
height: 10,
),
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
alignment: Alignment.center,
height: 50,
width: width,
color: primaryColor,
child: Text(
'Okay',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
],
),
);
请帮帮我。我期待着听到您的意见。提前谢谢你。
AlertDialog
在 AlertDialog
的右侧、左侧和底部有 default content padding
个 24
个逻辑像素,以将内容与其他边缘分开对话框..
要使 Button
适合 AlertDialog
宽度,您需要给 AlertDialog
一个 zero
的 padding
并应用 paddings
除了 Button
.
之外的其他小部件
我使用您的代码添加了一个示例:
AlertDialog(
// change the default padding to zero
contentPadding: EdgeInsets.zero,
title: Center(child: Text("Picture")),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
// wrap your container with a padding widget
Padding(
padding: const EdgeInsets.all(20.0), // give a preferred padding
child: Container(
width: width,
//height: height,
placeholder: kTransparentImage,
image: image.url,
),
),
),
SizedBox(
height: 10,
),
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
alignment: Alignment.center,
height: 50,
width: width,
color: primaryColor,
child: Text(
'Okay',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
],
),
);
我一直在尝试在 Flutter 的 AlertDialog
框中制作一个按钮。但是我找不到拉伸按钮容器的方法。请检查我的代码并查看下面的示例图片。
AlertDialog(
title: Center(child: Text("Picture")),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: width,
//height: height,
child: FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: image.url,
),
),
SizedBox(
height: 10,
),
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
alignment: Alignment.center,
height: 50,
width: width,
color: primaryColor,
child: Text(
'Okay',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
],
),
);
请帮帮我。我期待着听到您的意见。提前谢谢你。
AlertDialog
在 AlertDialog
的右侧、左侧和底部有 default content padding
个 24
个逻辑像素,以将内容与其他边缘分开对话框..
要使 Button
适合 AlertDialog
宽度,您需要给 AlertDialog
一个 zero
的 padding
并应用 paddings
除了 Button
.
我使用您的代码添加了一个示例:
AlertDialog(
// change the default padding to zero
contentPadding: EdgeInsets.zero,
title: Center(child: Text("Picture")),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
// wrap your container with a padding widget
Padding(
padding: const EdgeInsets.all(20.0), // give a preferred padding
child: Container(
width: width,
//height: height,
placeholder: kTransparentImage,
image: image.url,
),
),
),
SizedBox(
height: 10,
),
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
alignment: Alignment.center,
height: 50,
width: width,
color: primaryColor,
child: Text(
'Okay',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
],
),
);