1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import 'package:flutter/material.dart';
- import 'home.dart';
- import 'mine.dart';
- void main() {
- WidgetsFlutterBinding.ensureInitialized();
- runApp(BottomNavigationWidget());
- }
- class BottomNavigationWidget extends StatefulWidget {
- @override
- _BottomNavigationWidgetState createState() => _BottomNavigationWidgetState();
- }
- class _BottomNavigationWidgetState extends State<BottomNavigationWidget> {
- final bottomNavigationColor = Colors.blue;
- int curIndex = 0;
- List<Widget> pages = [];
- @override
- void initState() {
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- pages
- ..add(Home(context))
- ..add(Mine());
- return Scaffold(
- body: pages[curIndex],
- bottomNavigationBar: BottomNavigationBar(
- items: [
- BottomNavigationBarItem(
- icon: Icon(Icons.home, color: bottomNavigationColor),
- label: '首页',
- // title: Text('home1', style: TextStyle(color: bottomNavigationColor))
- ),
- BottomNavigationBarItem(
- icon: Icon(Icons.person, color: bottomNavigationColor),
- label: '我的',
- // title: Text('home', style: TextStyle(color: bottomNavigationColor))
- )
- ],
- currentIndex: curIndex,
- onTap: (int index) {
- setState(() {
- curIndex = index;
- });
- },
- fixedColor: Colors.blue,
- type: BottomNavigationBarType.fixed,
- ),
- );
- }
- }
|