feat:初始化工程
This commit is contained in:
60
lib/main.dart
Normal file
60
lib/main.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
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<StatefulWidget> createState() => _mainPage();
|
||||
}
|
||||
|
||||
class _mainPage extends State<MainPage> {
|
||||
int _currentIndex = 0;
|
||||
|
||||
final List<Widget> _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;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user