我正在制作一个自定义的AppBar,它的高度比典型的AppBar要大。我还想调整前导小部件/图标的大小,并利用automaticallyImplyLeading的默认行为(这样菜单图标和后退图标就会自动实现)。
这是我认为我会实现的解决方案:
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中(为了说明目的,文本大小明显变大),我想让自动添加的汉堡图标在比较中变得更大。

你认为如何?有没有解决这个问题的办法,或者我应该放弃自动图标,自己添加它们?
编辑:添加了一张图片,以显示我的意思
发布于 2021-06-11 23:30:42
要使用自定义的appBar前导按钮,代码如下。

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,
),
),
),
],
),
),
),https://stackoverflow.com/questions/52082857
复制相似问题