TabBar + TabBarView导航风格
Posted xiongwei
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TabBar + TabBarView导航风格相关的知识,希望对你有一定的参考价值。
import ‘package:flutter/material.dart‘; import ‘News.dart‘; import ‘Video.dart‘; import ‘Chat.dart‘; import ‘MyId.dart‘; class AppOne extends StatelessWidget { @override Widget build(BuildContext context) => new MaterialApp(home: MyHomePage()); } class MyHomePage extends StatefulWidget { @override State<StatefulWidget> createState() => new MyHomePageState(); } class MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin { TabController controller; @override void initState() { super.initState(); controller = new TabController(length: 3, vsync: this); } @override void dispose() { controller.dispose(); super.dispose(); } /// 相当于TabLayout 和 ViewPage @override Widget build(BuildContext context) { return new Scaffold( body: new TabBarView(controller: controller, children: <Widget>[ new NewsPage(), new VideoPage(), new ChatPage(), new MyIdPage() ]), bottomNavigationBar: new Material( color: Colors.blue, child: new TabBar( controller: controller, tabs: <Tab>[ new Tab(text: "首页", icon: new Icon(Icons.home)), new Tab(text: "列表", icon: new Icon(Icons.list)), new Tab(text: "信息", icon: new Icon(Icons.message)), ], indicatorWeight: 0.1, ), ), ); } }
以上是关于TabBar + TabBarView导航风格的主要内容,如果未能解决你的问题,请参考以下文章
13-3使用TabBar+TabBarView 实现旅拍可滑动切换多Tab
关于swift 自定义TabBarView使用系统tabar遇到的问题