Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

uinavigationbar - How to modify the default top navigation bar style in flutter

I want to make a top navigation bar with this effect, but it's very difficult to modify the default tab style of tabcontroller! Then I try to use container to modify it by myself. It's very simple, but the problem is that I can't support left and right swiping to switch pages. Because the gesture has been blocked by pageview. So in the end, I think it's better to use the tab provided by the system and then modify the style, some one help me!

enter image description here enter image description here

DefaultTabController(
      length: 3,
      child: Scaffold(
        appBar: AppBar(
          bottom: TabBar(
            tabs: [
              Tab(icon: Icon(Icons.directions_car)),
              Tab(icon: Icon(Icons.directions_transit)),
            ],
          ),
        ),
      ),
    );

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The indicator property of TabBar can be used to achieve the look. In your case, try this-

DefaultTabController(
  length: 3,
  child: Scaffold(
    appBar: AppBar(
      bottom: Container(
        color: Colors.grey[200],
        width: 200,
        child:TabBar(
        labelColor: Colors.red,
        unselectedLabelColor: Colors.grey,
        indicator: BoxDecoration(
            borderRadius: BorderRadius.circular(20),
            color: Colors.white),
        tabs: [
          Tab(icon: Icon(Icons.directions_car)),
          Tab(icon: Icon(Icons.directions_transit)),
        ],
      ),
    ),
  ),
);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...