1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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<StatefulWidget> createState() {
- return _GamePageState();
- }
- }
- class _GamePageState extends State<GamePage> with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin{
- TabController _tabController;
- List<Widget> _pages = [];
- @override
- void initState(){
- super.initState();
- _tabController = new TabController(length: 2, vsync: this);
- _pages = <Widget>[ // 运动的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: <Widget>[
- Tab(
- text: "运动",
- ),
- Tab(
- text:"榜单"
- )
- ],
- controller: _tabController,
- ),
- ),
- ),
- body: Container(
- color: Colors.white,
- child: TabBarView(
- controller: _tabController,
- children: _pages,
- ),
- )
- );
- }
- }
|