flutter - 尝试将样式主题添加到 BottomNavigationBarItem 中的标题时,我收到“无效的常量值”
问题描述
我在 BottomNavigationBarItem 的标题中添加了一个主题,我收到错误“无效的常量值”。
我知道这不是我正在使用的主题类型,因为我能够分解我的主题方法并在下一个 BottomNavigationBarItem 中使用各个常量。嗯,我打算张贴一张照片,显示我在这里的意思,但我想我还不能。
这是告诉我我有无效常量值的代码
BottomNavigationBarItem(
icon: Icon(CustomIcons.wrestlingring2),
title: Text('Event', style: Theme.of(context).textTheme.button),
),
这段代码是我在样式页面中的 buttonTheme 方法中直接将 const 值添加到样式的地方
BottomNavigationBarItem(
icon: Icon(CustomIcons.wrestling),
title: Text('Match Details', style: TextStyle(fontFamily: montserratFont, fontSize: smallTextSize, color: textColorLight)),
),
这是样式页面中的常量值和按钮主题
const smallTextSize = 14.0;
const Color buttonTextColour = Color(0xffdc0000);
const String montserratFont = 'Montserrat';
const buttonTextStyle = TextStyle(
fontFamily: montserratFont,
fontSize: buttonTextSize,
color: textColorLight,
);
我注意到在颤振代码中,BottomNavigationBarItem 是一个常量,并认为这可能是问题所在
const BottomNavigationBarItem({
@required this.icon,
this.title,
Widget activeIcon,
this.backgroundColor,
}) : activeIcon = activeIcon ?? icon,
assert(icon != null);
但后来我注意到 RaisedButton 也是如此,但它不受我添加主题的影响。
const RaisedButton({
Key key,
@required VoidCallback onPressed,
ValueChanged<bool> onHighlightChanged,
ButtonTextTheme textTheme,
如果有另一种方法可以在 NavigationBarItem 中使用带有标题的主题,如果有人能指出来,我将不胜感激。我宁愿不必为整个 ButtomNavigationBar 设置主题。
解决方案
推荐阅读
- python - 如何定位键:值对的值部分内的特定元素?
- jss - 如何在 styled-jss 中给出有意义的类名?
- laravel - 在 Docker 中从 Laravel 执行 aristan 的问题
- error-handling - 为什么 ⎕SIGNAL 没有被 :: 错误守卫捕获?
- python - IndexError: index 255 is out of bounds for axis 2 with size 12. 这是什么意思以及如何解决?
- tableau-api - 基于 tableau 中的另一个值突出显示多个行值
- java - 如何为 WindowedStream 数据使用度量系统或类似的东西?
- java - 调用 getDeclaredAnnotation() 时出现 NoSuchMethodError
- android - 无法从 Android 增加 Firebase 数据库
- python-3.x - 400 资源名称应以“/projects/”开头
/"