index_page.dart 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_tracker/pages/home_page.dart';
  3. import 'package:flutter_tracker/pages/mine_page.dart';
  4. import 'package:flutter_tracker/pages/track_page.dart';
  5. class IndexPage extends StatefulWidget {
  6. const IndexPage({Key key}) : super(key: key);
  7. @override
  8. _IndexPageState createState() => _IndexPageState();
  9. }
  10. class _IndexPageState extends State<IndexPage> {
  11. int navIndex = 0;
  12. List<Widget> pages = [
  13. HomePage(url: "http://app.21jingji.com/html/2020yiqing/"),
  14. //https://xw.qq.com/act/qgfeiyan
  15. // https://www.ipe.org.cn/MapGZBD/XQMap.html
  16. //http://m.look.360.cn/subject/400?sign=360_6aa05217&stab=0
  17. const TrackPage(),
  18. MinePage(),
  19. ];
  20. Widget currentPage;
  21. @override
  22. void initState() {
  23. super.initState();
  24. currentPage = pages[navIndex];
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. return Scaffold(
  29. backgroundColor: const Color(0xF1F6F9ff),
  30. body: currentPage,
  31. bottomNavigationBar: BottomNavigationBar(
  32. type: BottomNavigationBarType.fixed,
  33. currentIndex: navIndex,
  34. items: const [
  35. BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
  36. BottomNavigationBarItem(icon: Icon(Icons.art_track), label: "追踪"),
  37. BottomNavigationBarItem(icon: Icon(Icons.person), label: "我的"),
  38. ],
  39. onTap: (index) {
  40. setState(() {
  41. navIndex = index;
  42. currentPage = pages[navIndex];
  43. });
  44. },
  45. ),
  46. );
  47. }
  48. }