// lib/modules/home/views/home_page.dart import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:problem_check_system/modules/home/controllers/home_controller.dart'; class HomePage extends GetView { const HomePage({super.key}); @override Widget build(BuildContext context) { return Obx( () => Scaffold( body: controller.pages[controller.selectedIndex.value], // 1. 将 BottomNavigationBar 替换为 NavigationBar bottomNavigationBar: NavigationBar( // 2. 将 'currentIndex' 属性重命名为 'selectedIndex' selectedIndex: controller.selectedIndex.value, // 3. 将 'onTap' 属性重命名为 'onDestinationSelected' onDestinationSelected: controller.changeIndex, // M3 风格调整 (可选, 但推荐) // 动画时长 animationDuration: const Duration(milliseconds: 800), // 4. 将 'items' 替换为 'destinations',并使用 NavigationDestination destinations: const [ NavigationDestination( // M3 的一个重要特性是区分选中和未选中的图标 icon: Icon(Icons.home_outlined, color: Colors.blue), selectedIcon: Icon(Icons.home, color: Colors.blue), label: '企业', ), NavigationDestination( icon: Icon(Icons.now_widgets_outlined, color: Colors.blue), selectedIcon: Icon(Icons.now_widgets, color: Colors.blue), label: '全部问题', ), NavigationDestination( icon: Icon(Icons.person_outline, color: Colors.blue), selectedIcon: Icon(Icons.person, color: Colors.blue), label: '我的', ), ], ), ), ); } }