【问题标题】:how to fix align issue on tabbar如何解决标签栏上的对齐问题
【发布时间】:2019-07-20 03:14:16
【问题描述】:

我想要这样的标签栏,我的标签很丑,还有这样的分隔线怎么加?

但我尝试了标签栏,

我的构建方法

  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 3,
        child: Scaffold(
          appBar: DashboardAppBar(),
          body: TabBarView(physics: NeverScrollableScrollPhysics(), children: [
            dashboardGridView(),
            Icon(Icons.directions_transit),
            Icon(Icons.directions_bike),
          ]),
        ));
  }

dashboardGridView() 类

导入'package:flutter/material.dart';

class DashboardAppBar extends StatelessWidget implements PreferredSizeWidget {
  const DashboardAppBar({
    Key key,
  }) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return AppBar(
       ...

我在 AppBar 底部属性上添加了标签栏

        bottom: TabBar(
           isScrollable: true,
            indicatorColor: Colors.black,
            controller: controller,
            indicator: UnderlineTabIndicator(

边框位置不对,如何解决?

                borderSide: BorderSide(
                  width: 4,
                  color: Color(0xFF646464),
                ),
                insets: EdgeInsets.only(
                    left: 0,
                    right: 8,
                    bottom: 4)),
            labelPadding: EdgeInsets.only(left: 0, right: 0),
            tabs: [

第一个标签

              Tab(
                icon: Icon(Icons.people),
                text: 'Category',
              ),

第二个标签

              Tab(
                icon: Icon(Icons.chat_bubble_outline),
                text: 'My Enquiries',
              ),

我加了按钮她?对吗?

              Tab(
                  child: Container(
                    width: 100.0,
                    child: RaisedButton.icon(
                        icon: Icon(Icons.speaker),
                        label: Text(
                          'Promotions',
                          style: TextStyle(color: Colors.white),
                        ),),)),]));}
  @override
  Size get preferredSize => Size.fromHeight(130.0);
}

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    删除labelPadding: EdgeInsets.only(left: 0, right: 0),

    【讨论】:

      猜你喜欢
      • 2021-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多