【发布时间】:2021-07-11 13:05:37
【问题描述】:
注意:我在 stackoverflow 上尝试过其他答案,但没有奏效。
我有一个 TabBar,想设置它的高度。
这是我的代码:
Widget getTabBar() {
return TabBar(
labelColor: LightTheme.TabIconColor,
indicatorColor: LightTheme.TabIconColor,
indicatorSize: TabBarIndicatorSize.tab,
tabs: [
Tab(
text: "Collect",
icon: Icon(
Icons.add_location,
size: 40,
)),
Tab(
text: "Deliver",
icon: Icon(
Icons.tour,
size: 40,
)),
],
);
}
这是我的应用程序的屏幕截图。如您所见,标题被剪掉了(短语“底部溢出 22 像素”):
这是屏幕的其余代码:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('Test'),
backgroundColor: LightTheme.AppBarColor,
),
body: DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
automaticallyImplyLeading: false,
flexibleSpace: getTabBar(),
),
body: getTabBarView(),
),
),
drawer: getDrawer(),
// Disable opening the drawer with a swipe gesture.
drawerEnableOpenDragGesture: false,
);
}
更新:我在控制台中收到以下消息。我尝试设置 BoxConstraint 但问题依然存在:
The specific RenderFlex in question is: RenderFlex#fe401 relayoutBoundary=up25 OVERFLOWING
... parentData: offset=Offset(0.0, 0.0) (can use size)
... constraints: BoxConstraints(0.0<=w<=173.7, 0.0<=h<=54.0)
... size: Size(40.0, 54.0)
... direction: vertical
... mainAxisAlignment: start
... mainAxisSize: max
... crossAxisAlignment: center
... verticalDirection: down
【问题讨论】: