dart - Flutter:Tabbar 的 spaceBetween 如何布局

标签 dart flutter

    final List<Tab> myTabs = <Tab>[
    new Tab(text: 'a'),
    new Tab(text: 'b'),
    new Tab(text: 'c'),
    new Tab(text: 'd'),
    new Tab(text: 'e'),
  ];

然后
    appBar: new AppBar(
          elevation: 0,
          title: _barSearch(),
          backgroundColor: Colors.white,
          bottom: TabBar(
            isScrollable: true,
            tabs: myTabs,
            labelColor: Color(0xffFF645C),
            labelStyle:TextStyle(fontSize: 14.0),
            unselectedLabelStyle:TextStyle(fontSize: 14.0),
            unselectedLabelColor: Color(0xff343434),
            indicatorColor: Color(0xffFF645C),
            indicatorSize: TabBarIndicatorSize.label,
            indicatorPadding: EdgeInsets.only(bottom: 8.0),
          ),
        ),

它显示了我如何使用标签栏。
但是现在,我发现我的 Tabbar 布局与 spaceAround 的布局相似。
enter image description here

但是我们的项目经理让我使用 spaceBetween。
enter image description here

最佳答案

没有办法在 TabBar 中做 Space-between,但这是我实现目标的方法:

  • 我将选项卡包装到对齐小部件,因为选项卡是小部件的列表并进行相应的更改。您可以根据需要进行修改,甚至可以使用 Positioned Widget 来实现相同的效果
     tabs: [
    
           Align(alignment: Alignment.centerLeft,child: 
             Tab(icon: Icon(Icons.directions_transit)),
           ),
           Tab(icon: Icon(Icons.directions_transit)),
           Align(alignment: Alignment.centerRight,child: 
             Tab(icon: Icon(Icons.directions_transit)),
           ),
          ],
    
  • 关于dart - Flutter:Tabbar 的 spaceBetween 如何布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54106938/

    相关文章:

    flutter CachedNetworkImage 无法按预期工作

    flutter - 返回 Future<Dynamic> 而不是 Bool

    flutter - 使用 dio formdata 上传图像 flutter web

    javascript - dart2js 代码如何比 javascript 更快?

    flutter - 将数据发送到新屏幕,但不知道如何设置

    Dart 测试命令行程序

    dart - Flutter中的NPM 'prestart'脚本等效

    ios - 升级firebase核心后flutter Ios构建失败

    dart - Flutter:我的对话框键盘溢出

    dart - 自定义Flutter TextField文本选择按钮