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 { final bottomNavigationColor = Colors.blue; int curIndex = 0; List pages = []; @override void initState() { super.initState(); } @override Widget build(BuildContext context) { pages ..add(Home(context)) ..add(Mine()); return MaterialApp( home: 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, ), ), ); } }