[Flutter] AppBar 使用 TabBar且去掉 Title
文章目录
使用 PreferredSize
class TabBarTestView extends StatelessWidget {
const TabBarTestView({super.key});
@override
Widget build(BuildContext context) {
return DefaultTabController(
initialIndex: 1,
length: 2,
child: Scaffold(
appBar: const PreferredSize(
preferredSize: Size.fromHeight(kToolbarHeight),
child: TabBar(tabs: <Widget>[
Tab(text: "Tab 1"),
Tab(text: "Tab 2"),
]),
),
body: TabBarView(
children: [...],
),
));
}
}
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论