index_page.dart 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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: "https://xw.qq.com/act/qgfeiyan"),
  14. //http://m.look.360.cn/subject/400?sign=360_6aa05217&stab=0
  15. // https://www.ipe.org.cn/MapGZBD/XQMap.html
  16. const TrackPage(),
  17. const MinePage(),
  18. ];
  19. Widget currentPage;
  20. @override
  21. void initState() {
  22. super.initState();
  23. currentPage = pages[navIndex];
  24. }
  25. @override
  26. Widget build(BuildContext context) {
  27. return Scaffold(
  28. backgroundColor: const Color(0xF1F6F9ff),
  29. body: currentPage,
  30. bottomNavigationBar: BottomNavigationBar(
  31. type: BottomNavigationBarType.fixed,
  32. currentIndex: navIndex,
  33. items: const [
  34. BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
  35. BottomNavigationBarItem(icon: Icon(Icons.art_track), label: "追踪"),
  36. BottomNavigationBarItem(icon: Icon(Icons.person), label: "我的"),
  37. ],
  38. onTap: (index) {
  39. setState(() {
  40. navIndex = index;
  41. currentPage = pages[navIndex];
  42. });
  43. },
  44. ),
  45. );
  46. }
  47. }