在BottomNavigationBar
中添加超过 3 个项目时,所有项目都会变成白色,并且在浅灰色背景下不可读。 此外,活动项目也是白色的,而不是提供的fixedColor
。 可以在此处找到最小的代码示例
另请参阅以下图片:
不适用
[✓] Flutter (on Mac OS X 10.13.1 17B1003, locale nl-NL, channel alpha)
• Flutter at /Users/dirk/Developer/flutter/sdk
• Framework revision 8f65fec5f5 (5 days ago), 2017-12-12 09:50:14 -0800
• Engine revision edaecdc8b8
• Tools Dart version 1.25.0-dev.11.0
• Engine Dart version 2.0.0-edge.d8ae797298c3a6cf8dc9f4558707bd2672224d3e
[✓] Android toolchain - develop for Android devices (Android SDK 26.0.0)
• Android SDK at /Users/dirk/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-26, build-tools 26.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
[-] iOS toolchain - develop for iOS devices (Xcode 9.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.2, Build version 9C40b
✗ libimobiledevice and ideviceinstaller are not installed. To install, run:
brew install --HEAD libimobiledevice
brew install ideviceinstaller
✗ ios-deploy not installed. To install:
brew install ios-deploy
• CocoaPods version 1.2.0
[✓] Android Studio (version 2.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
[✓] IntelliJ IDEA Ultimate Edition (version 2017.3)
• Flutter plugin version 20.0.3
• Dart plugin version 173.3727.108
[✓] Connected devices
• iPhone X • 9500EA8E-1292-4223-BFFF-1B2134D5C47C • ios • iOS 11.2 (simulator)
/cc @xster
cc @HansMuller ,我依稀记得看到过一个关于这个的旧错误,但我找不到它
使用时BottomNavigationBarType.fixed ok ,但使用时BottomNavigationBarType.shifting 错误
我也有这个问题。 有人知道怎么修这个东西吗?
对我来说同样的问题
我已将此添加到我们今年晚些时候要查看的内容列表中。 不过,如果有人有机会在我们开始之前查看代码并弄清楚发生了什么,我们将很乐意审查补丁。
当提供超过 3 个 BottomNavigationBar 项时,如果未指定类型,则根据https://docs.flutter.io/flutter/material/BottomNavigationBar/BottomNavigationBar.html更改为BottomNavigationBarType.shifting
。 这部分信息应该在课程的文档中突出显示。 很容易忽略它的位置(我忽略了它)。
当 BottomNavigationBar 的类型为BottomNavigationBarType.shifting
时,项目文本和图标通过 DefaultTextStyle 和 IconTheme 呈现为白色。 假设他们的BottomNavigationBarItem.backgroundColor
将被指定为对比色。 这显然令人困惑。
shifting
类型底部导航栏的总体想法是每个项目将具有不同的背景颜色(与白色形成对比),因为当项目被选中时,该颜色将成为整个导航栏的颜色。
BottomNavigationBar 和 NavigationBarItem 的文档需要改进。
@HansMuller谢谢,那行得通!
@HansMuller ,赞!
如果你不明白如何解决它:
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
我是唯一一个认为它不应该根据标签数量自动改变行为的人吗?
对我来说,期望不同的行为似乎并不直观。
谢谢你👍
谢谢。
我该怎么办,如果我不希望图标是白色的,但它应该有移动的行为?
为什么不直接将默认类型设为 .fixed?
我知道这个问题已经解决了,但即使文档已经很好地更新,它仍然感觉像是一个错误。
我建议使用四个项目修复默认值或修复 BottomNavigationBarType.shifting 的行为。
我为每个“BottomNavigationBarItem”提供了“backgroundColor”agrument,问题就解决了。
我设法通过在底部导航栏中输入 showUnselectedLabels: true 属性来解决问题
返回新的底部导航栏(
showUnselectedLabels: true,
items: <BottomNavigationBarItem>[...
如果我们有超过三个项目,我们不希望行为发生变化。 有什么解决办法吗?
将showUnselectedLabels:true添加到 BottomNavigationBar
将 backgroundColor: Colors.blue 添加到 BottomNavigationBarItem
然后全部显示
我是唯一一个认为我不应该根据标签数量自动改变行为的人吗?
期望不同的行为对我来说似乎并不直观。
我也是这么想
最有用的评论
如果你不明白如何解决它: