共计 374 个字符,预计需要花费 1 分钟才能阅读完成。
应用 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: [...], | |
), | |
)); | |
} | |
} |
正文完