如何保证顶部和左侧领先的图标颤动
How to margin top and left the leading Icon flutter
关于 Apppbar 上的 margin-left 和 top 有问题,我正在使用 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')
,
)
这是屏幕截图:
我认为您不能轻易更改有关 layout of the 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')),
),
),
],
),
),
),
);
}
关于 Apppbar 上的 margin-left 和 top 有问题,我正在使用 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')
,
)
这是屏幕截图:
我认为您不能轻易更改有关 layout of the 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')),
),
),
],
),
),
),
);
}