[英]How to use Multiple Widget In Stack with different Position with showDialog in Flutter
I have a popup to refer a friend in my app, in this popup i am using image.我有一个弹出窗口可以在我的应用程序中推荐朋友,在这个弹出窗口中我使用的是图像。
So in this image bottom have tap to refer and T&C Apply, so i have to set the button on both TAP TO REFER and * T&C Apply So how i can do this.所以在这张图片底部有点击引用和 T&C Apply,所以我必须在TAP TO REFER和 * T&C Apply上设置按钮所以我该怎么做。
I have already set the close button on top right corner.我已经在右上角设置了关闭按钮。
Below is my Popup Code.下面是我的弹出代码。
Future<bool> referCard() async {
return await showDialog(
context: context,
builder: (context) => Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Stack(
children: [
Image.asset(
"assets/images/ref_card.jpg",
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Material(
color: Colors.transparent,
child: IconButton(
icon: Icon(
Icons.close,
color: Colors.grey,
),
onPressed: () {
Navigator.pop(context);
},
),
)
],
),
],
),
),
)) ??
false;
}
Please Help Me.请帮我。 Thank You.谢谢你。
So this is what I achieved based on how I understood your question.所以这就是我根据我对你的问题的理解所取得的成就。
Note: Wrap your parent widget with Material
and I also cropped your image to obtain your illustration image注意:用Material
包裹你的父小部件,我还裁剪了你的图像以获得你的插图图像
Also I user a black container color as the background:see the comment我也使用黑色容器颜色作为背景:见评论
showDialog(
context: context,
builder: (context) => Center(
child: Material(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Stack(
children: [
Container(color: Colors.black,),///black container as background
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Material(
color: Colors.transparent,
child: IconButton(
icon: Icon(
Icons.close,
color: Colors.grey,
),
onPressed: () {
Navigator.pop(context);
},
),
)
],
),
Center(
child: Image.asset("assets/v.jpg"),
),
const Center(
child: Text(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit", style: TextStyle(color: Colors.white, fontSize: 28.0),textAlign: TextAlign.center,)),
const SizedBox(
height: 10.0,
),
Center(
child: Container(
height: 50,
width: 160,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(8.0)
),
child: const Center(child: Text("Tap to Refer", style: TextStyle(color: Colors.black, fontSize: 28),)),
),
),
SizedBox(height: 10.0,),
Center(child: Text("*T&C Apply", style: TextStyle(color: Colors.white, fontSize: 28),)),
],
),
)
],
),
),
),
))
Container(
height:400,//use your height and width
width:300
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('assets/images/ref_card'))),
child: Padding(
padding: const EdgeInsets.only(bottom: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(onPressed: () {}, child: Text('TO REFER')),
TextButton(onPressed: () {}, child: Text('*T&C Apply')),
],
),
),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.