static_shortcuts 0.0.1
static_shortcuts: ^0.0.1 copied to clipboard
Generate and handle static shortcuts for Android.
Generate and handle static shortcuts for Android. They can trigger custom actions inside of your app.
[GIF]
Getting Started #
Dependency #
Add your launcher_name configuration to your pubspec.yaml as shown below. For each shortcut, you have to define the intent, that is accessible from within your app, a targetClass and a targetPackage, which help to identify the main Kotlin or Java file of your project, and a label, which will be visible for the user.
dependencies:
static_shortcuts: ^0.0.1 # check the latest version on pub.dev
# define your shortcuts here
static_shortcuts:
foo:
icon: "assets/add_icon.png"
intent: "foo"
targetClass: "com.OJCreator.static_shortcuts.MainActivity"
targetPackage: "com.OJCreator.static_shortcuts"
label: "Foo"
bar:
intent: "bar"
targetClass: "com.OJCreator.static_shortcuts.MainActivity"
targetPackage: "com.OJCreator.static_shortcuts"
label: "Bar"
When you specified your shortcuts, run dart run static_shortcuts in your console.
Access the intent #
You can access the intent at any moment, that has been used to launch the app:
import 'package:static_shortcuts/static_shortcuts.dart';
final shortcut = await StaticShortcuts.getShortcutIntentUri();
Localization #
You can localize the launcher name like this:
static_shortcuts:
foo:
icon: "assets/add_icon.png"
intent: "foo"
targetClass: "com.OJCreator.static_shortcuts.MainActivity"
targetPackage: "com.OJCreator.static_shortcuts"
label:
default: "Default (English) foo"
de: "German foo"
fr: "French foo"
es: "Spanish foo"
[...]
But make sure to add a default language for users, that do not use one of the other specified languages.