Flutter 聚焦菜单在模拟器中工作但在真实设备中不起作用

发布于 2025-01-16 01:47:36 字数 2178 浏览 2 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

水中月 2025-01-23 01:47:36

我找到了答案,

因为我的手机处于深色模式,所以项目中的文本不可见。

I found the answer,

Because my phone was on dark mode the text in the items were not visible.

笔芯 2025-01-23 01:47:36

我也有同样的问题。我在 Chrome 或模拟器中看不到项目文本。将 ThemeData.dark 更改为 ThemeData.light,它按照操作建议工作:


      debugShowCheckedModeBanner: false,
      theme: ThemeData.light().copyWith(

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:


      debugShowCheckedModeBanner: false,
      theme: ThemeData.light().copyWith(
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文