首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >调整flutter AppBar中前导小部件的大小

调整flutter AppBar中前导小部件的大小
EN

Stack Overflow用户
提问于 2018-08-30 01:11:33
回答 6查看 7.8K关注 0票数 8

我正在制作一个自定义的AppBar,它的高度比典型的AppBar要大。我还想调整前导小部件/图标的大小,并利用automaticallyImplyLeading的默认行为(这样菜单图标和后退图标就会自动实现)。

这是我认为我会实现的解决方案:

代码语言:javascript
运行
复制
class AppAppBar extends PreferredSize{
  AppAppBar(String title) : super(
    preferredSize: Size.fromHeight(56.0),
    child: AppBar(
      centerTitle: true,
      title: Text(title, style: textStyle)
    )) {
    (child as AppBar).leading = 
        SizedBox(width: 30.0, height: 30.0, child: (child as AppBar).leading);
  }

  static const textStyle = TextStyle(fontSize: 32.0);
}

但这当然不会起作用,因为(child as AppBar).leading是最终版本。

因此,在下面的AppBar中(为了说明目的,文本大小明显变大),我想让自动添加的汉堡图标在比较中变得更大。

你认为如何?有没有解决这个问题的办法,或者我应该放弃自动图标,自己添加它们?

编辑:添加了一张图片,以显示我的意思

EN

Stack Overflow用户

发布于 2021-06-11 23:30:42

要使用自定义的appBar前导按钮,代码如下。

代码语言:javascript
运行
复制
 appBar: AppBar(
    title: Text('hello'),
    // automaticallyImplyLeading: false,
    elevation: 0,
    leadingWidth: 58,

    actions: [
      ProfileBar(),
    ],
    leading: Container(
      width: 14,
      //color: Colors.yellow,
      child: Row( // <--- Using row to avoid force resizing of leading 
        children: [
          Padding( // <--- Padding to make it look more nicer
            padding: const EdgeInsets.only(left: 24.0),
            child: GestureDetector(
              onTap: () {
                Navigator.of(context).pop();
              },
              child: SvgPicture.asset( // <-- Using SvgPicture package
                'assets/svg/icons/backbtn.svg',
                width: 24,
                height: 24,
              ),
            ),
          ),
        ],
      ),
    ),
  ),
票数 0
EN
查看全部 6 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52082857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档