在尝试运行Chrome版本时,我会收到以下错误:
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
lib/src/screens/Dashboard.dart:64:17: Error: No named parameter with the name 'title'.
title: Text(
^^^^^
/usr/local/Caskroom/flutter/2.10.3/flutter/packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart:25:9: Context: Found this candidate, but the arguments don't match.
const BottomNavigationBarItem({在代码中,它是这样写的:
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Fryo.shop),
title: Text(
'Store',
style: tabLinkStyle,
)),我猜这与移动版本和网络版本有关,所以我可能需要添加一个参数,它可以忽略这个网页版本。
这是我的第一个应用程序,我使用的代码是一个拷贝,我使用的是3年前,所以我在更新它时遇到了各种各样的问题。这个特殊的问题可能是因为它一开始就没有用网络版本来构建。无论如何,任何帮助都将不胜感激。
发布于 2022-04-22 16:39:17
尝试标签而不是标题。
但是只有字符串,而不是小部件。
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Fryo.shop),
label:'Store',
),const BottomNavigationBarItem(
{required Widget icon,
String? label,
Widget? activeIcon,
Color? backgroundColor,
String? tooltip}
)发布于 2022-04-22 17:31:20
错误是很明显的。
“没有名称为‘title’的命名参数”,这意味着BottomNavigationBarItem没有title属性
根据https://api.flutter.dev/flutter/widgets/BottomNavigationBarItem-class.html
您应该使用label属性。
https://stackoverflow.com/questions/71971826
复制相似问题