flutter 底部导航BottomNavigationBar,案例
import 'package:flutter/material.dart'; class BottomNav extends StatefulWidget { const BottomNav({super.key}); @override State<BottomNav> createState() => _BottomNavState(); } class _BottomNavState extends State<BottomNav> { final _BottomColor = Colors.blue; late int currentIndex = 2; @override void initState() { super.initState(); currentIndex = 0; } @override Widget build(BuildContext context) { //return const Placeholder(); return Scaffold( bottomNavigationBar: BottomNavigationBar( selectedItemColor: Colors.red, currentIndex: currentIndex, type: BottomNavigationBarType.fixed, onTap: (value) => { setState(() { currentIndex = value; }) }, items: [ BottomNavigationBarItem( icon: Icon( Icons.home, ), label: "Home", ), BottomNavigationBarItem( icon: Icon( Icons.email, ), label: "Email", ), BottomNavigationBarItem( icon: Icon(IconData(0xe600, fontFamily: 'iconfont') //Icons.airplay, ), label: "Airplay", ), BottomNavigationBarItem( icon: Icon( Icons.pages, ), label: "Pages", ), ], ), ); } }
https://blog.csdn.net/juer2017/article/details/131707666

浙公网安备 33010602011771号