Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter shortcuts

flutter plugin for creating static & dynamic app shortcuts on the home screen.

68747470733a2f2f692e696d6775722e636f6d2f343632593677662e676966

why use flutter shortcuts?

flutter shortcuts plugin is known for :

flutter shortcuts
fast, performant & compatible
free & open-source
production ready
make app reactive

features

all the features listed below can be performed at the runtime.

✅   create shortcuts
✅   clear shortcuts
✅   update shortcuts
✅   use both flutter and android asset as shortcut icon

demo

68747470733a2f2f692e696d6775722e636f6d2f5550637950456c2e676966

quick start

step 1: include plugin to your project

dependencies:
  flutter_shortcuts: <latest version>

run pub get and get packages.

step 2: instantiate flutter shortcuts plugin

final fluttershortcuts fluttershortcuts = fluttershortcuts();

step 3: initialize flutter shortcuts

fluttershortcuts.initialize(debug: true);

example

define shortcut action

fluttershortcuts.listenaction((string incomingaction) {
    setstate(() {
    if (incomingaction != null) {
        action = incomingaction;
    }
  });
});

get max shortcut limit

return the maximum number of static and dynamic shortcuts that each launcher icon can have at a time.

int? result = await fluttershortcuts.getmaxshortcutlimit();

shortcut icon asset

flutter shortcuts allows you to create shortcut icon from both android drawable or mipmap and flutter assets.

  • if you want to use icon from android resources, drawable or mipmap.

use: shortcuticonasset.androidasset

fluttershortcutitem(
  id: "2",
  action: 'bookmark page action',
  shortlabel: 'bookmark page',
  icon: "ic_launcher",
  shortcuticonasset: shortcuticonasset.androidasset,
),
  • if you want to create shortcut icon from flutter asset. (default)

use: shortcuticonasset.flutterasset

fluttershortcutitem(
  id: "2",
  action: 'bookmark page action',
  shortlabel: 'bookmark page',
  icon: 'assets/icons/bookmark.png',
  shortcuticonasset: shortcuticonasset.flutterasset,
),

set shortcut items

publishes the list of shortcuts. all existing shortcuts will be replaced.

fluttershortcuts.setshortcutitems(
  shortcutitems: <fluttershortcutitem>[
    const fluttershortcutitem(
      id: "1",
      action: 'home page action',
      shortlabel: 'home page',
      icon: 'assets/icons/home.png',
    ),
    const fluttershortcutitem(
      id: "2",
      action: 'bookmark page action',
      shortlabel: 'bookmark page',
      icon: "ic_launcher",
      shortcuticonasset: shortcuticonasset.androidasset,
    ),
  ],
),

clear shortcut item

delete all dynamic shortcuts from the app.

fluttershortcuts.clearshortcutitems();

push shortcut item

push a new shortcut item. if there is already a dynamic or pinned shortcut with the same id, the shortcut will be updated and pushed at the end of the shortcut list.

fluttershortcuts.pushshortcutitem(
  shortcut: fluttershortcutitem(
    id: "5",
    action: "play music action",
    shortlabel: "play music",
    icon: 'assets/icons/music.png',
  ),
);

push shortcut items

pushes a list of shortcut item. if there is already a dynamic or pinned shortcut with the same id, the shortcut will be updated and pushed at the end of the shortcut list.

fluttershortcuts.pushshortcutitems(
  shortcutlist: <fluttershortcutitem>[
    const fluttershortcutitem(
      id: "1",
      action: 'home page new action',
      shortlabel: 'home page',
      icon: 'assets/icons/home.png',
    ),
    const fluttershortcutitem(
      id: "2",
      action: 'bookmark page new action',
      shortlabel: 'bookmark page',
      icon: 'assets/icons/bookmark.png',
    ),
    const fluttershortcutitem(
      id: "3",
      action: 'settings action',
      shortlabel: 'setting',
      icon: 'assets/icons/settings.png',
    ),
  ],
);

update shortcut item

updates a single shortcut item based on id. if the id of the shortcut is not same, no changes will be reflected.

fluttershortcuts.updateshortcutitem(
  shortcut: fluttershortcutitem(
    id: "1",
    action: 'go to url action',
    shortlabel: 'visit page',
    icon: 'assets/icons/url.png',
  ),
);

update shortcut items

updates shortcut items. if the ids of the shortcuts are not same, no changes will be reflected.

fluttershortcuts.updateshortcutitems(
 shortcutlist: <fluttershortcutitem>[
   const fluttershortcutitem(
     id: "1",
     action: 'resume playing action',
     shortlabel: 'resume playing',
     icon: 'assets/icons/play.png',
   ),
   const fluttershortcutitem(
     id: "2",
     action: 'search songs action',
     shortlabel: 'search songs',
     icon: 'assets/icons/search.png',
   ),
 ],
);

change shortcut item icon

change the icon of the shortcut based on id. if the id of the shortcut is not same, no changes will be reflected.

fluttershortcuts.changeshortcutitemicon(
  id: "2",
  icon: "assets/icons/next.png",
);

get shortcut icon properties

get the icon properties of your shortcut icon.

map<string, int> result = await fluttershortcuts.geticonproperties();
print( "maxheight: ${result["maxheight"]}, maxwidth: ${result["maxwidth"]}");

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.