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')
,
)
这是屏幕截图:
解决方案
我认为您无法轻松更改有关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')),
),
),
],
),
),
),
);
}
推荐阅读
- websphere - 如何下载 com.ibm.ws.orb_8.5.0.jar
- javascript - 如何创建用于 TypeScript 泛型的 JavaScript 变量
- javascript - 在 React 功能组件中调用了两次 setTimeout 回调?
- python - 如何将输入整数限制为个位数?[Python]
- react-native - 在不使用输入字段的情况下确定在 React Native 上按下了哪个键
- java - 检索保存到数据库中的 pdf 文件,以便在 pdfbox 中进行操作。Springbot 和休眠应用程序
- jquery - Rails 6 Webpack JQuery Yarn - Bootstrap 汉堡菜单不起作用的问题
- postgresql - Postgres - 创建一个列(更改表)作为其他两列的计算
- python - 有没有办法分配多个变量而无需手动编写它们?
- memory - 当最差匹配成功时,最佳匹配内存分配是否总是成功?