dart - 当溢出为溢出时,IconButton 的 onPressed 不会在堆栈小部件内被调用。
问题描述
我有以下代码
void showShortBioDialog(BuildContext context) {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Dialog(
child: Stack(
overflow: Overflow.visible,
children: <Widget>[
Container(
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 10, 0, 40),
child: Text(
"Short Bio",
textAlign: TextAlign.center,
style: TextStyle(color: white, fontFamily: "BarlowBold"),
),
),
color: blue2,
width: double.infinity,
),
Positioned(
top: 30,
right: -5,
left: -5,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),
elevation: 0,
child: Container(
height: 180,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: TextField(),
),
),
),
),
Positioned(
bottom: -170,
right: 0,
left: 0,
child: IconButton(
onPressed: () {
print("hi");
},
iconSize: 35,
icon: Image.asset(
"images/next_signup.webp",
fit: BoxFit.fill,
height: 35,
width: 35,
),
),
)
],
),
);
});
}
对话框看起来像我想要的那样正确,并且在屏幕出现时触发对话框。但iconbutton's
onPressed
从未调用过我尝试用 , 等替换图标按钮InkWell
,RaisedButton
但FlatButton
从未onPressed
调用过该按钮。图标按钮的位置也在堆栈的最后,但我仍然很困惑为什么不调用它的点击。
我想要一个类似于以下的输出
https://drive.google.com/file/d/1K12-Dw4xRzHNd9N1gM02TcHd6TdK319Y/view?usp=sharing
解决方案
我认为是因为溢出。如果您发表评论overflow: Overflow.visible
,那么您将根本看不到图像。尝试使对话框足够大,以使图像位于顶部而不会溢出。
推荐阅读
- algorithm - O(m+n) 与 O(m) /O(n)
- python - 如何从字符串中删除最后两个数字?
- c# - 无法使用 c# 将公式导出到 .xlsx 电子表格
- facebook-graph-api - 如何创建或修改 facebook messenger webhook 回调 url
- javascript - 基于字符串在模板文字中选择一个选项
- netty - 如果没有客户端连接,是否有办法在一段时间内发生 Bind 超时后向 Netty 指示
- c# - Apache Spark 数据帧到 C# 中的 csv 导出
- javascript - 我如何将通过函数输入的按钮输入到 index.html?
- linux - 默认情况下,如何在后台运行所有 shell 命令并重定向输出?
- c - linux内核中的错误@sk_prot_alloc+0x9a/0x150