如何增加 AppBar flutter 前导图标的大小
How to increase on the size of the leading icon off an AppBar flutter
我正在寻找增加 Appbar 前导图标大小的方法。下面是我的代码
:
appBar: PreferredSize(
preferredSize: Size.fromHeight(120.0),
child: AppBar(
leading: SizedBox(
width: 200,
height: 200,
child: IconButton(
padding: new EdgeInsets.all(0.0),
icon: Image.asset('assets/app_logo.png', height: 700.0, width: 700.0,)
,
)),
centerTitle: true,
actions: <Widget>[
IconButton(
icon: Image.asset('assets/path.png'))
],
bottom: TabBar(
labelColor: Colors.white,
indicatorColor: Colors.lime,
tabs:[
Tab(icon: null,text: 'RECENT',),
Tab(icon: null, text: 'TOPICS',),
Tab(icon: null, text: 'AUTHORS',),
]
),
)
从上面的代码来看,具体我实现的大小如下,但是不行:
child: AppBar(
leading: SizedBox(
width: 200,
height: 200,
child: IconButton(
padding: new EdgeInsets.all(0.0),
icon: Image.asset('assets/app_logo.png', height: 700.0, width: 700.0,)
,
)),
我的目标是将右上角的图标增加得更大,但并没有增加它的大小。
截图如下:
您可以通过将 IconButton
换成 Transform.scale
并将 scale
值传递为 2 来增加图标的大小,具体取决于您希望图标的大小。下面的工作示例代码:
centerTitle: true,
actions: <Widget>[
Transform.scale(
scale: 2,
child: IconButton(
icon: Image.asset('assets/placeholder.png'))
),
],
这会增加应用栏右上角图标的大小,如:
您可以根据需要调整比例,也可以对左上角的图标应用相同的更改。
希望这能回答您的问题。
使用Transform.scale不太对,有更简单的方法可以达到预期效果。
AppBar(
toolbarHeight: 100, //set height appBar
leading: Image.asset('image/my_logo.png', width: 120, height: 100), //insert logo image
leadingWidth: 120, //set leading height. By default width is 56
)
我正在寻找增加 Appbar 前导图标大小的方法。下面是我的代码 :
appBar: PreferredSize(
preferredSize: Size.fromHeight(120.0),
child: AppBar(
leading: SizedBox(
width: 200,
height: 200,
child: IconButton(
padding: new EdgeInsets.all(0.0),
icon: Image.asset('assets/app_logo.png', height: 700.0, width: 700.0,)
,
)),
centerTitle: true,
actions: <Widget>[
IconButton(
icon: Image.asset('assets/path.png'))
],
bottom: TabBar(
labelColor: Colors.white,
indicatorColor: Colors.lime,
tabs:[
Tab(icon: null,text: 'RECENT',),
Tab(icon: null, text: 'TOPICS',),
Tab(icon: null, text: 'AUTHORS',),
]
),
)
从上面的代码来看,具体我实现的大小如下,但是不行:
child: AppBar(
leading: SizedBox(
width: 200,
height: 200,
child: IconButton(
padding: new EdgeInsets.all(0.0),
icon: Image.asset('assets/app_logo.png', height: 700.0, width: 700.0,)
,
)),
我的目标是将右上角的图标增加得更大,但并没有增加它的大小。
截图如下:
您可以通过将 IconButton
换成 Transform.scale
并将 scale
值传递为 2 来增加图标的大小,具体取决于您希望图标的大小。下面的工作示例代码:
centerTitle: true,
actions: <Widget>[
Transform.scale(
scale: 2,
child: IconButton(
icon: Image.asset('assets/placeholder.png'))
),
],
这会增加应用栏右上角图标的大小,如:
您可以根据需要调整比例,也可以对左上角的图标应用相同的更改。
希望这能回答您的问题。
使用Transform.scale不太对,有更简单的方法可以达到预期效果。
AppBar(
toolbarHeight: 100, //set height appBar
leading: Image.asset('image/my_logo.png', width: 120, height: 100), //insert logo image
leadingWidth: 120, //set leading height. By default width is 56
)