請告訴我如何在 TabBar 中洗掉這種隱藏的嘗試。我使用容器來指定大小,但它不會改變選項卡的大小。我認為通過使用指標大小,可以做到,但不確定如何以及哪種方法最適合這些情況。

這是代碼 -
bottom: TabBar(
unselectedLabelColor: Colors.white,
labelColor: Colors.white,
tabs: [
Container(
width: 100,
child: const Tab(
text: 'Attempted',
),
),
Container(
width: 120,
child: const Tab(
text: 'Booked',
),
),
Container(
width: 80,
child: const Tab(
text: 'Travelled',
),
),
Container(
width: 100,
child: const Tab(
text: 'Cancelled',
),
),
],
controller: _tabController,
indicatorColor: Colors.white,
indicatorSize: TabBarIndicatorSize.tab,
uj5u.com熱心網友回復:
嘗試添加isScrollable屬性
TabBar(
isScrollable: true,
tabs: []
)
uj5u.com熱心網友回復:
您的第一個選項卡文本Attempted比Container的寬度長,不適合您的容器。您可以洗掉所有容器小部件并像這樣使用FittedBox小部件。
tabs: const [
FittedBox(
child: Tab(
text: 'Attempted',
),
),
FittedBox(
child: Tab(
text: 'Booked',
),
),
FittedBox(
child: Tab(
text: 'Travelled',
),
),
FittedBox(
child: Tab(
text: 'Cancelled',
),
),
],
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/395303.html
