标签之间的颤动标签栏Margin/padding

flutter tabbar Margin/padding between label

我厌倦了标签栏,但没有找到答案。我有 3 个标签栏,我想将标签放在左侧,如类别,如何?

我想要标签栏 enter image description here

我的标签栏 enter image description here

我的代码

       // 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',
                ),
              ],
            ),
          ),
        ),
      ),

我能找到解决办法。

只需将 isScrollable: true 参数添加到 TabBar() 所有选项卡都收缩到一侧。

在没有设置 isScrollable: true 的情况下,所有选项卡项目都占用了给定小部件中的所有 space。

尝试在 TabBar() 小部件中添加 isScrollable: true,

参考标签栏 here

参考isScrollablehere

   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',
                ),
              ],
            ),
          ),
        ),
      ),

您的结果屏幕->

bottom:  PreferredSize(
        preferredSize: const Size.fromHeight(kToolbarHeight),
        child: Align(
          alignment: Alignment.centerLeft,
          child: Container(
            width: MediaQuery.of(context).size.width / 1.1,
            child: TabBar(
              isScrollable: true,
              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',
                ),
              ],
            ),
          ),
        ),
      )