41 lines
1008 B
Dart
41 lines
1008 B
Dart
import 'package:flutter/material.dart';
|
|
import 'calculator_home_page.dart';
|
|
import 'about_page.dart';
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
const HomeScreen({super.key});
|
|
|
|
@override
|
|
State<HomeScreen> createState() => _HomeScreenState();
|
|
}
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
int _selectedIndex = 0;
|
|
|
|
static const List<Widget> _widgetOptions = <Widget>[
|
|
CalculatorHomePage(),
|
|
AboutPage(),
|
|
];
|
|
|
|
void _onItemTapped(int index) {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: _widgetOptions.elementAt(_selectedIndex),
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
items: const <BottomNavigationBarItem>[
|
|
BottomNavigationBarItem(icon: Icon(Icons.calculate), label: '计算'),
|
|
BottomNavigationBarItem(icon: Icon(Icons.info), label: '关于'),
|
|
],
|
|
currentIndex: _selectedIndex,
|
|
onTap: _onItemTapped,
|
|
),
|
|
);
|
|
}
|
|
}
|