Flutter AppBar 图标在所有屏幕上均不响应

标签 flutter flutter-layout flutter-appbar

我的应用程序栏上有两个图标,单击保存保存图标消失,批准图标将弹出,它工作正常,但通过较大屏幕上的应用程序栏图标根据下图进行剪切。这是我的代码

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(),
        ],
      //),
      ),
    ),

这是我在大屏幕上的应用栏 enter image description here 这是我在小屏幕上的图像 enter image description here

那么我怎样才能使图标响应谢谢

最佳答案

将您的 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(
            ...

关于Flutter AppBar 图标在所有屏幕上均不响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63532719/

相关文章:

flutter - 如何将PX值转换为flutter字体大小

flutter - 使用 Navigator.push (MaterialPageRoute) 而不是 AlertDialog

flutter - 如何在运行时枚举 flutter 小部件树?

java - Workmanager(registerPeriodicTask)出现抖动,但我的应用程序每次在后台运行时都会崩溃

flutter - pushReplacement 或 pushAndRemoveUntil(Route<dynamic> route) => false 不起作用

android - 如何在flutter中实现Socket IO客户端数据

firebase - flutter: 'String'类型不是 'List<dynamic>'类型的子类型

flutter - 如何在 Flutter 左侧放置 AppBar 标题

flutter - 如何在 Appbar 左侧创建按钮 [flutter]

Android 的 onStart 等价物