As a developer, you can define shortcuts to perform specific actions in your app. These shortcuts can be displayed in a supported launcher and help your users quickly start common or recommended tasks within your app.
Android and IOS both have their specific ways implement these shortcuts. In Android, the term used is App Shortcut whereas IOS calls it as Home Screen Quick Actions.
To achieve this functionality in Flutter you can use a plugin called quick_actions. This Flutter plugin allows you to manage and interact with the application’s home screen quick actions.
Quick actions refer to the eponymous concept on iOS and to the App Shortcuts APIs on Android (introduced in Android 7.1 / API level 25). It is safe to run this plugin with earlier versions of Android as it will have any impact on the app.
name: quick_action
description: A new Flutter application which demonstrates use of quick actions.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
quick_actions: ^0.3.0+1
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
**import **‘package:quick_actions/quick_actions.dart’;
final QuickActions quickActions = const QuickActions();
quickActions.initialize((String shortcutType) {
if (shortcutType == 'action_decrement') {
print('The user tapped on the "decrement" action.');
} else {
print('The user tapped on the "increment" action.');
}
});
quickActions.setShortcutItems(<ShortcutItem>[
const ShortcutItem(
type: 'action_decrement', localizedTitle: 'decrement', icon: 'minus'),
const ShortcutItem(
type: 'action_increment', localizedTitle: 'increment', icon: 'plus')
]);
Please note, that the type
argument should be unique within your application (among all the registered shortcut items). 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.
this is our output
Code is here
#flutter #mobile-apps #ios