dart导航
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override // ignore: library_private_types_in_public_api _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int currentIndex = 0; void onTap(int index) { setState(() { currentIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text('Selected index: $currentIndex'), ), bottomNavigationBar: BottomNavigationBar( currentIndex: currentIndex, onTap: onTap, items: const [ BottomNavigationBarItem(icon: Icon(Icons.category), label: '收货'), BottomNavigationBarItem(icon: Icon(Icons.email), label: '记录'), //BottomNavigationBarItem(icon: Icon(Icons.label), label: '位置'), BottomNavigationBarItem(icon: Icon(Icons.settings), label: '自己'), ], ), ); } }