Flutter 聚焦菜单在模拟器中工作但在真实设备中不起作用
在 Flutter 中,我有一个来自以下包的焦点菜单: https://pub.dev/packages/focused_menu/安装。我有最新版本,代码看起来没问题。但问题是它可以在 IOS 和 Android 模拟器上运行,但不能在我或我朋友的 iPhone 上运行。显示焦点菜单,但项目为空且不包含任何文本或图标。
List<FocusedMenuItem>? createLanguages() {
List<FocusedMenuItem> languages = [
FocusedMenuItem(title: Text("Share"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
FocusedMenuItem(title: Text("Share2"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
FocusedMenuItem(title: Text("Share3"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
];
return languages;
}
下面使用 createLanguages 的地方:
FocusedMenuHolder(
child: Image.asset(
country_flags[whichFlag],
package: 'country_icons',
width: 1.25 * AppBar().preferredSize.height,
height: 1.25 * AppBar().preferredSize.height,
),
menuItems: createLanguages()!,
onPressed: () {
},
openWithTap: true,
)
我也尝试直接在 FocusedMenuHolder 中执行此操作,但这也不起作用。 FocuesMenuHolder 与空项目的图片
FocusedMenuHolder(
child: Image.asset(
country_flags[whichFlag],
package: 'country_icons',
width: 1.25 * AppBar().preferredSize.height,
height: 1.25 * AppBar().preferredSize.height,
),
menuItems: <FocusedMenuItem>[
FocusedMenuItem(title: Text("Share"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
FocusedMenuItem(title: Text("Share2"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
FocusedMenuItem(title: Text("Share3"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
],
onPressed: () {
},
openWithTap: true,
)
感谢您的宝贵时间:)
In Flutter I have an Focus Menu from the following package: https://pub.dev/packages/focused_menu/install. I have the latest version and the code looks alright. The problem however is that it works on both IOS and android emulators, but it doesn't work on my or my friends Iphones. The Focused menu is displayed but the items are empty and do not contain any text or icons.
List<FocusedMenuItem>? createLanguages() {
List<FocusedMenuItem> languages = [
FocusedMenuItem(title: Text("Share"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
FocusedMenuItem(title: Text("Share2"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
FocusedMenuItem(title: Text("Share3"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
];
return languages;
}
Where the createLanguages is used below:
FocusedMenuHolder(
child: Image.asset(
country_flags[whichFlag],
package: 'country_icons',
width: 1.25 * AppBar().preferredSize.height,
height: 1.25 * AppBar().preferredSize.height,
),
menuItems: createLanguages()!,
onPressed: () {
},
openWithTap: true,
)
I also tried to do it directly in the FocusedMenuHolder but that dit not work also.Picture of FocuesMenuHolder with empty items
FocusedMenuHolder(
child: Image.asset(
country_flags[whichFlag],
package: 'country_icons',
width: 1.25 * AppBar().preferredSize.height,
height: 1.25 * AppBar().preferredSize.height,
),
menuItems: <FocusedMenuItem>[
FocusedMenuItem(title: Text("Share"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
FocusedMenuItem(title: Text("Share2"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
FocusedMenuItem(title: Text("Share3"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
],
onPressed: () {
},
openWithTap: true,
)
Thanks for your time :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了答案,
因为我的手机处于深色模式,所以项目中的文本不可见。
I found the answer,
Because my phone was on dark mode the text in the items were not visible.
我也有同样的问题。我在 Chrome 或模拟器中看不到项目文本。将 ThemeData.dark 更改为 ThemeData.light,它按照操作建议工作:
I had the same problem. I couldn't see the items texts in chrome or my emulators. Changed ThemeData.dark to ThemeData.light and it worked as the op suggested: