import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:sport/pages/game/game_info.dart'; import 'package:sport/pages/game/rank_info.dart'; class GamePage extends StatefulWidget{ @override State createState() { return _GamePageState(); } } class _GamePageState extends State with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin{ TabController _tabController; List _pages = []; @override void initState(){ super.initState(); _tabController = new TabController(length: 2, vsync: this); _pages = [ // 运动的View GameInfoView(), // 榜单的View RankInfo(),]; } @override void dispose() { super.dispose(); _tabController?.dispose(); } @override bool get wantKeepAlive => true; @override void didChangeDependencies() { super.didChangeDependencies(); } @override Widget build(BuildContext context) { super.build(context); return Scaffold( backgroundColor: Colors.white, appBar: AppBar( elevation: 0, // 去掉AppBar下面的阴影 title: SizedBox( height: 30, child: TabBar( isScrollable: true, indicatorPadding: EdgeInsets.symmetric(horizontal: 10.0), indicatorWeight: 3, labelStyle:TextStyle(fontSize: 18.0,fontWeight: FontWeight.w600), unselectedLabelStyle: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w600), labelPadding:EdgeInsets.symmetric(vertical: 0.0,horizontal: 30.0), // indicator: const BoxDecoration(), // labelPadding: EdgeInsets.all(20.0), tabs: [ Tab( text: "运动", ), Tab( text:"榜单" ) ], controller: _tabController, ), ), ), body: Container( color: Colors.white, child: TabBarView( controller: _tabController, children: _pages, ), ) ); } }