Flutter基础(前端教程①①-底部导航栏)

1. 主页面(BottomNavBarPage)
  • _currentBarIndex 记录当前选中的导航索引(默认 0,即首页)。
  • IndexedStack 管理 4 个页面,通过 _currentBarIndex 控制显示哪个页面(比如索引 1 就显示 NodePage)。
  • 底部导航栏用 CustomNavigationBar 组件,传递当前索引和点击回调。
2. 底部导航栏(CustomNavigationBar)
  • 定义了 4 个导航项(NavItem),每个包含标题、图标、是否选中(isHighlighted)。
  • 通过 Row 横向排列 4 个导航项,每个占满屏幕宽度的 1/4(Expanded 组件实现)。
  • 点击导航项时,触发 onTap 回调,更新 _currentBarIndex 切换页面。
3. 导航项样式(选中 / 未选中)
  • 未选中状态_buildIconContainer):灰色图标,无背景。
  • 选中状态_buildHighlightedIconContainer):白色图标,带渐变绿色椭圆形背景(有边框),文字也变为亮绿色。
  • 通过 isHighlighted 判断状态,动态切换样式。
相关推荐
星秋Eliot8 小时前
认识 Flutter
flutter
tangweiguo030519878 小时前
Flutter 根据后台配置动态生成页面完全指南
flutter
stringwu8 小时前
Flutter开发者必备:状态管理Bloc的实用详解
前端·flutter
humiaor20 小时前
Flutter之riverpod状态管理详解
flutter·provider·riverpod
浮生若茶80881 天前
创建Flutter项目的两种方式
flutter
RaidenLiu1 天前
Riverpod 3:组合与参数化的进阶实践
前端·flutter
ideal树叶1 天前
Provider中的watch、read、Consumer、ChangeNotifierProvider、ValueNotifierProvider
flutter
勤劳打代码1 天前
独辟蹊径 —— NSIS 自定义 EXE 应用名称
windows·flutter
阿笑带你学前端1 天前
当手机遇上电视:Flutter实现局域网遥控输入的奇妙之旅
前端·flutter
早起的年轻人1 天前
Flutter 3.35.2 以上版本中 数字转字符串的方法指南
前端·flutter