WallPaper_ZZH_Flutter/wallpaper/lib/TestApp.dart
2024-05-11 10:43:00 +08:00

64 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
class BottomNavigationBarLnt extends StatefulWidget {
const BottomNavigationBarLnt({super.key});
@override
State<BottomNavigationBarLnt> createState() => _BottomNavigationBarLntState();
}
class _BottomNavigationBarLntState extends State<BottomNavigationBarLnt>{
int _cuurentIndex = 0;
@override
Widget build(BuildContext context) {
final List<Widget> chiledList = [Center(child: const Text("dddddsaaaafdajl",style: TextStyle(color: Colors.red),),),const Text("aaa"),const Text("eeee"),const Text("rrrr")];
final List<BottomNavigationBarItem> listItem = <BottomNavigationBarItem>[
const BottomNavigationBarItem(
icon: Icon(Icons.home),
label: "Home"
),
const BottomNavigationBarItem(
icon: Icon(Icons.book),
label: "Collection"
),
const BottomNavigationBarItem(
icon: Icon(Icons.music_video),
label: "My"
),
const BottomNavigationBarItem(
icon: Icon(Icons.movie),
label: "Setting"
),
];
return MaterialApp(
home: Scaffold(
bottomNavigationBar: BottomNavigationBar(
items: listItem,
// fixedColor: Colors.blue,
unselectedItemColor:Colors.grey,
selectedItemColor: Colors.orange,
type: BottomNavigationBarType.fixed,
selectedFontSize: 14,
unselectedFontSize: 14,
currentIndex: _cuurentIndex,
onTap: _onItemTapped,
),
body: chiledList[_cuurentIndex],
),
);
}
void _onItemTapped(int index) {
setState(() {
_cuurentIndex = index;
});
}
}