12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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(
- 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,
- ),
- )
- );
- }
- }
|