flutter - Flutter AppBar Icon 在所有屏幕上都没有响应
问题描述
我的应用栏上有两个图标,点击保存保存图标 dissappers 和批准图标会弹出它工作正常,但根据下图切割大屏幕上的应用栏图标。这是我的代码
appBar: PreferredSize(
preferredSize: Size.fromHeight(70.0),
child: AppBar(
elevation: 10,
automaticallyImplyLeading: false,
backgroundColor: Colors.red,
title: Text('Edit',style:
TextStyle(fontSize: MediaQuery.of(context).size.width*0.1),
),
actions: <Widget>[
isVisibile
? Container(
height: 50,
width: 50,
child: Padding(
padding: EdgeInsets.only(right:MediaQuery.of(context).size.width*0.3),
child: IconButton(
icon: Icon(
Icons.save,
color: Colors.white,
size: MediaQuery.of(context).size.width*0.1,
),
onPressed: () {
},
),
),
)
: Container(),
isInvisible
? Padding(
padding: EdgeInsets.only(right:MediaQuery.of(context).size.width*0.05,bottom: MediaQuery.of(context).size.height*0.05),
child: IconButton(
icon: Icon(
Icons.done,
color: Colors.white,
size: MediaQuery.of(context).size.width*0.1,
),
onPressed: () async {
// approve
},
),
)
: Container(),
],
//),
),
),
所以我怎样才能让图标响应谢谢
解决方案
将您的 AppBar 小部件作为子级Container
并将边距设置为EdgeInset.all(4)
. 这应该有效。
尝试以下代码:
appBar: PreferredSize(
preferredSize: Size.fromHeight(70.0),
child: Container(
padding: EdgeInset.all(4), // you can change this value to 8
child:AppBar(
...