[英]How to margin top and left the leading Icon flutter
我在 Apppbar 上的左边距和顶部遇到问题,正在使用leading
图标,但我未能重新定位它。
下面是我的代码:
child: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(150.0),
child: AppBar(
leading: SizedBox(
width: 200,
height: 200,
child: Transform.scale(scale: 2,
child: IconButton(
icon: Image.asset('assets/app_logo.png')
,
),
)
),
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',),
]
),
)
这是我为leading
图标设置样式的地方:
leading: SizedBox(
width: 200,
height: 200,
child: Transform.scale(scale: 2,
child: IconButton(
icon: Image.asset('assets/app_logo.png')
,
)
这是屏幕截图:
我认为您无法轻松更改有关AppBar 布局的领先小部件的大小
但是您可以使用Stack
小部件将您的徽标放在 AppBar 上,如下所示:
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(150.0),
child: Stack(
children: <Widget>[
AppBar(
bottom: TabBar(
controller: _tabController,
labelColor: Colors.white,
indicatorColor: Colors.lime,
tabs: [
Tab(
icon: null,
text: 'RECENT',
),
Tab(
icon: null,
text: 'TOPICS',
),
Tab(
icon: null,
text: 'AUTHORS',
),
],
),
),
Container(
padding: EdgeInsets.only(left: 20, top: 60),
child: Container(
width: 50,
height: 50,
color: Colors.yellow,
child: Center(child: Text('Logo')),
),
),
],
),
),
),
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.