Quick Action in Flutter怎么设置icon?

Flutter开发,为App添加了一个Quick Action功能,桌面快捷菜单,但是这个菜单图标怎么配置呢?quick_action这个包里icon居然是个string类型,不知道怎么设置

flutter
112 views
Comments
登录后评论
Sign In
·

虽然我没用过这个quick_action,不过网上查一下就能看到一些用法(我没试过,你可以试一下)

Here, the icon string is the name of the icon image native resource folder without extension, for example, xcassets on iOS or drawable on Android.

甚至有直接放一个路径的

const ShortcutItem(
      id: "2",
      action: 'Search Songs Action',
      shortLabel: 'Search Songs',
      icon: 'assets/icons/search.png',
    ),

你看看能不能用吧

·

它不是说了吗?

The optional icon should be the name of the native resource (xcassets on iOS or drawable on Android) that the app will display for the quick action.

以 Android 为例,你要在 drawable 上放一个资源,叫 xxxx.png, 然后flutter 这边写死就这个名字即可