【发布时间】:2021-11-03 23:54:08
【问题描述】:
首先,看一下应用栏的图像,标题上方有多余的空间(忽略红色文本)。
其次是我的代码:
caffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
elevation: 0,
titleSpacing: 10,
centerTitle: false,
title: Text(
'Profile',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
backgroundColor: Colors.red),
),
// toolbarHeight: 10,
backgroundColor: Colors.amberAccent,
// flexibleSpace: Align(
// alignment: Alignment.centerLeft,
// child: Container(
// width: double.infinity,
// margin: EdgeInsets.only(left: 20),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(
// 'Profile',
// style: TextStyle(
// fontSize: 20, fontWeight: FontWeight.w600),
// ),
// Align(
// alignment: Alignment.centerRight,
// child: Visibility(
// child: Container(
// height: 100,
// margin: EdgeInsets.only(right: 5, top: 0.0),
// padding: EdgeInsets.only(top: 0.0),
// child: IconButton(
// icon: Icon(
// Icons.close,
// color:
// isDark ? Colors.white : Colors.black87,
// size: 25,
// ),
// onPressed: () {
// setState(() {
// editCheck = false;
// showClose = false;
// });
// }),
// ),
// visible: showClose,
// ),
// ),
// ],
// )),
// ),
actions: [
Visibility(
child: Container(
height: 100,
margin: EdgeInsets.only(right: 5, top: 0.0),
padding: EdgeInsets.only(top: 0.0),
child: IconButton(
icon: Icon(
Icons.close,
color: isDark ? Colors.white : Colors.black87,
size: 25,
),
onPressed: () {
setState(() {
editCheck = false;
showClose = false;
});
}),
),
visible: showClose,
),
],
),
现在真正的问题来了,正如您所见,我已经注释掉了 FlexibleSpace 代码,因为该代码有效,但 FlexibleSpace 中的关闭按钮“X”在 iOS 中不起作用,但在 Android 中却可以正常工作。所以请帮我删除标题上方的这个多余的空间。
谢谢
【问题讨论】:
-
用safeArea包裹脚手架怎么样?
-
我也做过,但还是不行
-
@YeasinSheikh 我不知道如何,但安全区现在正在工作。
-
@YeasinSheikh 你能回答这个问题吗(与评论相同),所以它可以被标记为已解决(你也得到了代表)
标签: android ios flutter appbar