【问题标题】:Flutter AppBar Icon is not responsive on all screensFlutter AppBar Icon 在所有屏幕上都没有响应
【发布时间】:2020-12-11 10:07:55
【问题描述】:

我的应用栏上有两个图标点击保存保存图标消散器和批准图标会弹出它工作正常,但根据下图切割大屏幕上的应用栏图标。这是我的代码

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

这是我在大屏幕上的应用栏 这是我在小屏幕上的图像

所以我怎样才能让图标响应谢谢

【问题讨论】:

    标签: flutter flutter-layout flutter-appbar


    【解决方案1】:

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

    【讨论】:

    • Jay Dangar 它可以工作,有错误容器边距我纠正它填充谢谢
    猜你喜欢
    • 1970-01-01
    • 2020-12-30
    • 1970-01-01
    • 2021-12-18
    • 2022-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多