我有 3 TabBars,我想将标签放置在类别的左侧。
我TabBar想要的:

我的TabBar:

我的代码:
// BOTTOM
bottom: PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight),
child: Align(
alignment: Alignment.centerLeft,
child: Container(
width: MediaQuery.of(context).size.width / 1.1,
child: TabBar(
labelPadding: EdgeInsets.all(0),
labelColor: Colors.white,
labelStyle: poppins.copyWith(
fontSize: 15,
fontWeight: bold,
),
unselectedLabelColor: Color(0xff585861),
indicatorColor: Colors.white,
indicatorSize: TabBarIndicatorSize.label,
// TABS
tabs: [
Tab(
text: 'Following',
),
Tab(
text: 'Trending',
),
Tab(
text: 'Search',
),
],
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
请参阅下面的代码并尝试添加 isScrollable: true,内部TabBar()小部件
请参阅此处的选项卡栏
请参阅此处可滚动
bottom: PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight),
child: Align(
alignment: Alignment.centerLeft,
child: Container(
width: MediaQuery.of(context).size.width / 1.1,
child: TabBar(
labelPadding: EdgeInsets.all(5),
labelColor: Colors.white,
isScrollable: true,// add this property
unselectedLabelColor: Color(0xff585861),
indicatorColor: Colors.white,
indicatorSize: TabBarIndicatorSize.label,
// TABS
tabs: [
Tab(
text: 'Following',
),
Tab(
text: 'Trending',
),
Tab(
text: 'Search',
),
],
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8375 次 |
| 最近记录: |