代码之家  ›  专栏  ›  技术社区  ›  Francois Tonnel

为什么我的tabBar上出现了一条意想不到的灰色线条?

  •  0
  • Francois Tonnel  · 技术社区  · 2 年前

    我尝试在flutter应用程序上为导航做一个简单的选项卡。我想在任何地方都有相同的背景。但我看到我的tabBar和页面之间有一条灰色的线。我不知道如何让它消失。也许很简单,对不起,我是一个初学者。这是我的代码:

    class Homelogin extends StatefulWidget {
      const Homelogin({Key? key}) : super(key: key);
    
      @override
      HomeloginState createState() => HomeloginState();
    }
    
    class HomeloginState extends State<Homelogin>
        with SingleTickerProviderStateMixin {
      late TabController _tabController;
    
      @override
      void initState() {
        super.initState();
        _tabController = TabController(length: 2, vsync: this);
      }
    
      @override
      Widget build(BuildContext context) {
        // Définir la couleur de la barre de statut
        SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
          statusBarColor: Colors.grey[900], 
          statusBarIconBrightness: Brightness
              .light, 
        ));
        return Scaffold(
          body: Column(
            children: [
              SafeArea(
                child: Container(
                  color: Colors.grey[900],
                  child: Padding(
                    padding: const EdgeInsets.only(top: 10.0),
                    child: TabBar(
                      splashBorderRadius: null,
                      controller: _tabController,
                      indicatorColor: Colors.deepPurple,
                      indicatorWeight: 5,
                      tabs: [
                        Tab(text: 'Log in'),
                        Tab(text: 'Sign up'),
                      ],
                    ),
                  ),
                ),
              ),
              Expanded(
                child: TabBarView(
                  controller: _tabController,
                  children: [
                    Loginpage(),
                    Newaccountpage(),
                  ],
                ),
              ),
            ],
          ),
        );
      }
    }
    
    

    结果如下 unexpected grey line

    我尝试了很多事情,比如我只为tabBar做了一个新项目,并在youtube上遵循教程,但我没有得到同样的结果——每次都有一条灰线。 我试着放一个盒子装饰,这样我就可以选择边框。。。不起作用我有选定颜色和灰色线的边框。我尝试过这些解决方案 Flutter Tabbarview underline color 也不要工作。我想也许灰色的线不属于虎斑。

    1 回复  |  直到 2 年前
        1
  •  0
  •   Dhafin Rayhan    2 年前

    它是分隔器。可以将颜色设置为透明。

    TabBar(
      dividerColor: Colors.transparent,
      // ...
    )