【发布时间】:2021-04-15 04:41:56
【问题描述】:
Flutter 选项卡栏,选中的选项卡栏指示器和每个选项卡的大小不相等。我使用带有指示器装饰的选定指示器,并使用 PreferredSized 将每个选项卡包装在容器内。但是不能对齐。如何与所选指标和每个容器对齐等于?
This is my screen shot of the tab bar problem.
bottom: PreferredSize(
preferredSize: Size(40, 40),
child: Container(
height: getScreenHeightRation(40.0),
decoration: BoxDecoration(
color: Color(0xFFF0C185),
border: Border.all(color: Colors.grey[600]),
),
child: TabBar(
indicatorPadding: EdgeInsets.symmetric(horizontal: 40),
indicatorSize: TabBarIndicatorSize.tab,
indicatorColor: Colors.transparent,
indicator: BoxDecoration(
color: Color(0xFFD2A368),
),
tabs: [
Container(
decoration: BoxDecoration(
border: Border(right: BorderSide(color: Colors.grey))
),
child: Tab(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ImageIcon(AssetImage('assets/images/icon_ext/menu.png')),
SizedBox(
width: 5.0,
),
],
),
),
),
Container(
width: 150,
decoration: BoxDecoration(
border: Border(right: BorderSide(color: Colors.grey))
),
child: Tab(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ImageIcon(AssetImage('assets/images/icon_ext/image.png')),
SizedBox(
width: 5.0,
),
],
),
),
),
Container(
width: 150,
child: Tab(
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ImageIcon(
AssetImage('assets/images/icon_ext/placeholder.png')),
SizedBox(
width: 5.0,
),
],
),
),
)
],
controller: tabController,
),
),
),
【问题讨论】: