import 'package:flutter/material.dart'; import 'package:food_hub_app/profile.dart'; import 'package:food_hub_app/record.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp(debugShowCheckedModeBanner: false, home: MainPage()); } } class MainPage extends StatefulWidget { const MainPage({super.key}); @override State createState() => _mainPage(); } class _mainPage extends State { int _currentIndex = 0; final List _tabPages = const [RecordPage(), ProfilePage()]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("食光集", style: TextStyle(fontSize: 18)), backgroundColor: Colors.green, ), backgroundColor: Color(0xFFF5F5F5), body: _tabPages[_currentIndex], bottomNavigationBar: BottomNavigationBar( currentIndex: _currentIndex, fixedColor: Colors.green, iconSize: 25, type: BottomNavigationBarType.fixed, items: const [ BottomNavigationBarItem(icon: Icon(Icons.home), label: "记录"), BottomNavigationBarItem( icon: Icon(Icons.account_circle), label: "我的", ), ], onTap: (index) { setState(() { _currentIndex = index; }); }, ), ); } }