import 'package:flutter/material.dart'; import 'package:flutter_tracker/pages/home_page.dart'; import 'package:flutter_tracker/pages/mine_page.dart'; import 'package:flutter_tracker/pages/track_page.dart'; class IndexPage extends StatefulWidget { const IndexPage({Key key}) : super(key: key); @override _IndexPageState createState() => _IndexPageState(); } class _IndexPageState extends State { int navIndex = 0; List pages = [ HomePage(url: "http://app.21jingji.com/html/2020yiqing/"), //https://xw.qq.com/act/qgfeiyan // https://www.ipe.org.cn/MapGZBD/XQMap.html //http://m.look.360.cn/subject/400?sign=360_6aa05217&stab=0 const TrackPage(), MinePage(), ]; Widget currentPage; @override void initState() { super.initState(); currentPage = pages[navIndex]; } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: const Color(0xF1F6F9ff), body: currentPage, bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: navIndex, items: const [ BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"), BottomNavigationBarItem(icon: Icon(Icons.art_track), label: "追踪"), BottomNavigationBarItem(icon: Icon(Icons.person), label: "我的"), ], onTap: (index) { setState(() { navIndex = index; currentPage = pages[navIndex]; }); }, ), ); } }