├── .github
├── CODEOWNERS
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── BUG_REPORT.md
│ └── FEATURE_REQUEST.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ └── ci.yml
├── .gitignore
├── .idea
├── flutter_shortcuts.iml
├── libraries
│ ├── Dart_SDK.xml
│ └── Flutter_Plugins.xml
├── misc.xml
├── modules.xml
├── vcs.xml
└── workspace.xml
├── .metadata
├── CHANGELOG.md
├── LICENSE
├── README.md
├── android
├── .classpath
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── .name
│ ├── caches
│ │ └── build_file_checksums.ser
│ ├── compiler.xml
│ ├── gradle.xml
│ ├── jarRepositories.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── vcs.xml
├── .project
├── .settings
│ └── org.eclipse.buildship.core.prefs
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── settings.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── divyanshushekhar
│ └── flutter_shortcuts
│ ├── FlutterShortcutsPlugin.java
│ └── MethodCallImplementation.java
├── example
├── .gitignore
├── .metadata
├── README.md
├── android
│ ├── .gitignore
│ ├── .project
│ ├── .settings
│ │ └── org.eclipse.buildship.core.prefs
│ ├── app
│ │ ├── .classpath
│ │ ├── .project
│ │ ├── .settings
│ │ │ └── org.eclipse.buildship.core.prefs
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── divyanshushekhar
│ │ │ │ │ └── flutter_shortcuts_example
│ │ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ │ ├── drawable-v21
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable
│ │ │ │ ├── bookmark_icon.png
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values-night
│ │ │ │ └── styles.xml
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── assets
│ ├── icons
│ │ ├── arrows.png
│ │ ├── bookmark.png
│ │ ├── home.png
│ │ ├── music.png
│ │ ├── next.png
│ │ ├── play.png
│ │ ├── search.png
│ │ ├── settings.png
│ │ └── url.png
│ └── svg
│ │ ├── play-button.svg
│ │ ├── settings.svg
│ │ └── share.svg
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ └── WorkspaceSettings.xcsettings
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── Runner
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── Runner-Bridging-Header.h
├── lib
│ └── main.dart
├── pubspec.lock
├── pubspec.yaml
└── test
│ └── widget_test.dart
├── flutter_shortcuts.iml
├── ios
├── .gitignore
├── Assets
│ └── .gitkeep
├── Classes
│ ├── FlutterShortcutsPlugin.h
│ ├── FlutterShortcutsPlugin.m
│ └── SwiftFlutterShortcutsPlugin.swift
└── flutter_shortcuts.podspec
├── lib
├── flutter_shortcuts.dart
└── src
│ ├── helper
│ ├── action
│ │ └── shortcut_action.dart
│ ├── enums
│ │ └── shortcut_icon_asset.dart
│ ├── helper.dart
│ └── model
│ │ └── shortcut_item.dart
│ ├── method_call
│ └── flutter_shortcuts_method_call_handler.dart
│ └── platform
│ └── flutter_shortcuts_platform.dart
├── pubspec.lock
├── pubspec.yaml
└── test
└── flutter_shortcuts_test.dart
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Every request must be reviewed and accepted by:
2 |
3 | * @divshekhar
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [divshekhar]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: ["https://paypal.me/dshekhar17"]
13 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/BUG_REPORT.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 |
5 | ---
6 |
7 | **Describe the bug**
8 | A clear and concise description of what the bug is.
9 |
10 | **To Reproduce**
11 | Steps to reproduce the behavior:
12 | 1. Go to '...'
13 | 2. Click on '....'
14 | 3. Scroll down to '....'
15 | 4. See error
16 |
17 | **Expected behavior**
18 | A clear and concise description of what you expected to happen.
19 |
20 | **Screenshots**
21 | If applicable, add screenshots to help explain your problem.
22 |
23 | **Logs **
24 | Run `flutter analyze` and attach any output of that command below.
25 | If there are any analysis errors, try resolving them before filing this issue.
26 |
27 | Paste the output of running `flutter doctor -v` here.
28 |
29 | **Additional context**
30 | Add any other context about the problem here.
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 |
5 | ---
6 |
7 | **Is your feature request related to a problem? Please describe.**
8 | A clear and concise description of what the problem is.
9 |
10 | **Describe the solution you'd like**
11 | A clear and concise description of what you want to happen.
12 |
13 | **Describe alternatives you've considered**
14 | A clear and concise description of any alternative solutions or features you've considered.
15 |
16 | **Additional context**
17 | Add any other context or screenshots about the feature request here.
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
8 |
9 | ## Status
10 |
11 | **READY/IN DEVELOPMENT/HOLD**
12 |
13 | ## Breaking Changes
14 |
15 | YES | NO
16 |
17 | ## Description
18 |
19 |
20 |
21 | ## Type of Change
22 |
23 |
24 |
25 | - [ ] ✨ New feature (non-breaking change which adds functionality)
26 | - [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
27 | - [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change)
28 | - [ ] 🧹 Code refactor
29 | - [ ] ✅ Build configuration change
30 | - [ ] 📝 Documentation
31 | - [ ] 🗑️ Chore
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | pull_request:
5 | branches: [main]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - uses: actions/checkout@v2
13 | # Setup the flutter environment.
14 | - uses: subosito/flutter-action@v1.4.0
15 |
16 | - name: Install Dependencies
17 | run: flutter packages get
18 |
19 | - name: Format
20 | run: flutter format --set-exit-if-changed lib
21 |
22 | - name: Analyze
23 | run: flutter analyze --no-pub
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 |
--------------------------------------------------------------------------------
/.idea/flutter_shortcuts.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/libraries/Dart_SDK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/libraries/Flutter_Plugins.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 1622026976188
48 |
49 |
50 | 1622026976188
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 1d9032c7e1d867f071f2277eb1673e8f9b0274e3
8 | channel: stable
9 |
10 | project_type: plugin
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## v1.3.0
2 |
3 | * **Breaking Change** renamed `FlutterShortcutsItem` to `ShortcutItem`
4 | * Extra fields added in ShortcutItem
5 | * `(bool) conversationShortcut` make conversation shortcuts
6 | * `(bool) isImportant` set conversation shortcut importance
7 | * `(bool) isBot` set is conversation shortcut bot
8 |
9 | ## v1.2.2
10 |
11 | * Compatibility added in Readme
12 |
13 | ## v1.2.1
14 |
15 | * **Optimised Shortcuts**
16 | * Readme updated
17 |
18 | ## v1.2.0
19 |
20 | * **Breaking Change** renamed `initialize` to `listenAction`.
21 | * **Breaking Change** `initialize` takes bool debug.
22 |
23 | ## v1.1.0
24 |
25 | * **Breaking Change** `updateShortcutItem` doesn't take id.
26 | * **Breaking Change** `changeShortcutItemIcon` icon property is by default set to `ShortcutIconAsset.flutterAsset`.
27 | * **New Feature** `FlutterShortcutItem` new field `shortcutIconAsset`.
28 |
29 | ## v1.0.1
30 |
31 | * Demo provided in README
32 |
33 | ## v1.0.0
34 |
35 | * Initial Development Release
36 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | (c) Copyright 2021 divshekhar (Divyanshu Shekhar)
4 |
5 | Redistribution and use in source and binary forms, with or without modification,
6 | are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice,
9 | this list of conditions and the following disclaimer.
10 |
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | 3. Neither the name of the copyright holder nor the names of its contributors
16 | may be used to endorse or promote products derived from this software without
17 | specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 | THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Flutter Shortcuts
2 |
3 |
4 |
5 |        
6 |
7 | ## Compatibility
8 |
9 | ✅ Android
10 | ❌ iOS (active issue: [iOS support for quick actions](https://github.com/DevsOnFlutter/flutter_shortcuts/issues/1))
11 |
12 | ## Show some :heart: and :star: the repo
13 |
14 | ## Why use Flutter Shortcuts?
15 |
16 | Flutter Shortcuts Plugin is known for :
17 |
18 | | Flutter Shortcuts |
19 | | :--------------------------------- |
20 | | Fast, performant & compatible |
21 | | Free & Open-source |
22 | | Production ready |
23 | | Make App Reactive |
24 |
25 | ## Features
26 |
27 | All the features listed below can be performed at the runtime.
28 |
29 | ✅ Create Shortcuts
30 | ✅ Clear Shortcuts
31 | ✅ Update Shortcuts
32 | ✅ Conversation Shortcuts
33 | ✅ Use both flutter and android asset as shortcut icon
34 |
35 | ## Demo
36 |
37 | |
|
38 | |---|
39 |
40 | ## Quick Start
41 |
42 | ### Step 1: Include plugin to your project
43 |
44 | ```yml
45 | dependencies:
46 | flutter_shortcuts:
47 | ```
48 |
49 | Run pub get and get packages.
50 |
51 | ### Step 2: Instantiate Flutter Shortcuts Plugin
52 |
53 | ```dart
54 | final FlutterShortcuts flutterShortcuts = FlutterShortcuts();
55 | ```
56 |
57 | ### Step 3: Initialize Flutter Shortcuts
58 |
59 | ```dart
60 | flutterShortcuts.initialize(debug: true);
61 | ```
62 |
63 | ## Example
64 |
65 | ### Define Shortcut Action
66 |
67 | ```dart
68 | flutterShortcuts.listenAction((String incomingAction) {
69 | setState(() {
70 | if (incomingAction != null) {
71 | action = incomingAction;
72 | }
73 | });
74 | });
75 | ```
76 |
77 | ### Get Max Shortcut Limit
78 |
79 | Return the maximum number of static and dynamic shortcuts that each launcher icon can have at a time.
80 |
81 | ```dart
82 | int? result = await flutterShortcuts.getMaxShortcutLimit();
83 | ```
84 |
85 | ### Shortcut Icon Asset
86 |
87 | Flutter Shortcuts allows you to create shortcut icon from both android `drawable` or `mipmap` and flutter Assets.
88 |
89 | * If you want to use icon from Android resources, `drawable` or `mipmap`.
90 |
91 | use: `ShortcutIconAsset.androidAsset`
92 |
93 | ```dart
94 | ShortcutItem(
95 | id: "2",
96 | action: 'Bookmark page action',
97 | shortLabel: 'Bookmark Page',
98 | icon: "ic_launcher",
99 | shortcutIconAsset: ShortcutIconAsset.androidAsset,
100 | ),
101 | ```
102 |
103 | * If you want to create shortcut icon from flutter asset. (DEFAULT)
104 |
105 | use: `ShortcutIconAsset.flutterAsset`
106 |
107 | ```dart
108 | ShortcutItem(
109 | id: "2",
110 | action: 'Bookmark page action',
111 | shortLabel: 'Bookmark Page',
112 | icon: 'assets/icons/bookmark.png',
113 | shortcutIconAsset: ShortcutIconAsset.flutterAsset,
114 | ),
115 | ```
116 |
117 | ### Set shortcut items
118 |
119 | Publishes the list of shortcuts. All existing shortcuts will be replaced.
120 |
121 | ```dart
122 | flutterShortcuts.setShortcutItems(
123 | shortcutItems: [
124 | const ShortcutItem(
125 | id: "1",
126 | action: 'Home page action',
127 | shortLabel: 'Home Page',
128 | icon: 'assets/icons/home.png',
129 | ),
130 | const ShortcutItem(
131 | id: "2",
132 | action: 'Bookmark page action',
133 | shortLabel: 'Bookmark Page',
134 | icon: "ic_launcher",
135 | shortcutIconAsset: ShortcutIconAsset.androidAsset,
136 | ),
137 | ],
138 | ),
139 | ```
140 |
141 | ### Clear shortcut item
142 |
143 | Delete all dynamic shortcuts from the app.
144 |
145 | ```dart
146 | flutterShortcuts.clearShortcutItems();
147 | ```
148 |
149 | ### Push Shortcut Item
150 |
151 | 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.
152 |
153 | ```dart
154 | flutterShortcuts.pushShortcutItem(
155 | shortcut: ShortcutItem(
156 | id: "5",
157 | action: "Play Music Action",
158 | shortLabel: "Play Music",
159 | icon: 'assets/icons/music.png',
160 | ),
161 | );
162 | ```
163 |
164 | ### Push Shortcut Items
165 |
166 | 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.
167 |
168 | ```dart
169 | flutterShortcuts.pushShortcutItems(
170 | shortcutList: [
171 | const ShortcutItem(
172 | id: "1",
173 | action: 'Home page new action',
174 | shortLabel: 'Home Page',
175 | icon: 'assets/icons/home.png',
176 | ),
177 | const ShortcutItem(
178 | id: "2",
179 | action: 'Bookmark page new action',
180 | shortLabel: 'Bookmark Page',
181 | icon: 'assets/icons/bookmark.png',
182 | ),
183 | const ShortcutItem(
184 | id: "3",
185 | action: 'Settings Action',
186 | shortLabel: 'Setting',
187 | icon: 'assets/icons/settings.png',
188 | ),
189 | ],
190 | );
191 | ```
192 |
193 | ### Update Shortcut Item
194 |
195 | Updates a single shortcut item based on id. If the ID of the shortcut is not same, no changes will be reflected.
196 |
197 | ```dart
198 | flutterShortcuts.updateShortcutItem(
199 | shortcut: ShortcutItem(
200 | id: "1",
201 | action: 'Go to url action',
202 | shortLabel: 'Visit Page',
203 | icon: 'assets/icons/url.png',
204 | ),
205 | );
206 | ```
207 |
208 | ### Update Shortcut Items
209 |
210 | Updates shortcut items. If the IDs of the shortcuts are not same, no changes will be reflected.
211 |
212 | ```dart
213 | flutterShortcuts.updateShortcutItems(
214 | shortcutList: [
215 | const ShortcutItem(
216 | id: "1",
217 | action: 'Resume playing Action',
218 | shortLabel: 'Resume playing',
219 | icon: 'assets/icons/play.png',
220 | ),
221 | const ShortcutItem(
222 | id: "2",
223 | action: 'Search Songs Action',
224 | shortLabel: 'Search Songs',
225 | icon: 'assets/icons/search.png',
226 | ),
227 | ],
228 | );
229 | ```
230 |
231 | ### Set Conversation Shortcut
232 |
233 | Set `conversationShortcut: true` in ShortcutItem to make the shortcut as conversation shortcut.
234 |
235 | The conversation shortcut can also be set as important and bot by setting `isImportant: true` & `isBot: true`.
236 |
237 | ```dart
238 | await flutterShortcuts.pushShortcutItems(
239 | shortcutList: [
240 | const ShortcutItem(
241 | id: "1",
242 | action: 'open_chat_1',
243 | shortLabel: 'Divyanshu Shekhar',
244 | icon: 'assets/icons/home.png',
245 | conversationShortcut: true,
246 | isImportant: true,
247 | ),
248 | const ShortcutItem(
249 | id: "2",
250 | action: 'oepn_chat_2',
251 | shortLabel: 'Subham Praharaj',
252 | icon: 'assets/icons/bookmark.png',
253 | conversationShortcut: true,
254 | ),
255 | const ShortcutItem(
256 | id: "3",
257 | action: 'oepn_chat_3',
258 | shortLabel: 'Auto Reply Bot',
259 | icon: 'assets/icons/url.png',
260 | conversationShortcut: true,
261 | isBot: true,
262 | ),
263 | ],
264 | );
265 | ```
266 |
267 | ### Change Shortcut Item Icon
268 |
269 | Change the icon of the shortcut based on id. If the ID of the shortcut is not same, no changes will be reflected.
270 |
271 | ```dart
272 | flutterShortcuts.changeShortcutItemIcon(
273 | id: "2",
274 | icon: "assets/icons/next.png",
275 | );
276 | ```
277 |
278 | ### Get shortcut icon properties
279 |
280 | Get the icon properties of your shortcut icon.
281 |
282 | ```dart
283 | Map result = await flutterShortcuts.getIconProperties();
284 | print( "maxHeight: ${result["maxHeight"]}, maxWidth: ${result["maxWidth"]}");
285 | ```
286 |
287 | ## Project Created & Maintained By
288 |
289 | ### Divyanshu Shekhar
290 |
291 |
292 |
293 | [](https://github.com/divshekhar/)
294 |
295 | ### Subham Praharaj
296 |
297 |
298 |
299 | [](https://github.com/skpraharaj/)
300 |
301 | ## Contributions
302 |
303 | Contributions are welcomed!
304 |
305 | If you feel that a hook is missing, feel free to open a pull-request.
306 |
307 | For a custom-hook to be merged, you will need to do the following:
308 |
309 | Describe the use-case.
310 |
311 | * Open an issue explaining why we need this hook, how to use it, ...
312 | This is important as a hook will not get merged if the hook doens't appeal to
313 | a large number of people.
314 |
315 | * If your hook is rejected, don't worry! A rejection doesn't mean that it won't
316 | be merged later in the future if more people shows an interest in it.
317 | In the mean-time, feel free to publish your hook as a package on https://pub.dev.
318 |
319 | * A hook will not be merged unles fully tested, to avoid breaking it inadvertendly
320 | in the future.
321 |
322 | ## Stargazers
323 | [](https://github.com/DevsOnFlutter/flutter_shortcuts/stargazers)
324 |
325 | ## Forkers
326 |
327 | [](https://github.com/DevsOnFlutter/flutter_shortcuts/network/members)
328 |
329 | ## Copyright & License
330 |
331 | Code and documentation Copyright (c) 2021 [Divyanshu Shekhar](https://hackthedeveloper.com). Code released under the [BSD 3-Clause License](./LICENSE).
332 |
--------------------------------------------------------------------------------
/android/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/android/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/android/.idea/.name:
--------------------------------------------------------------------------------
1 | flutter_shortcuts
--------------------------------------------------------------------------------
/android/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevsOnFlutter/flutter_shortcuts/cb797b0b39f51f91801e2fd2b3461701f99fc72f/android/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/android/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/android/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/android/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/android/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | flutter_shortcuts
4 | Project android created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
25 | 0
26 |
27 | 30
28 |
29 | org.eclipse.core.resources.regexFilterMatcher
30 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/android/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | arguments=
2 | auto.sync=false
3 | build.scans.enabled=false
4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.1.1))
5 | connection.project.dir=
6 | eclipse.preferences.version=1
7 | gradle.user.home=
8 | java.home=C\:/Program Files/AdoptOpenJDK/jdk-15.0.2.7-hotspot
9 | jvm.arguments=
10 | offline.mode=false
11 | override.workspace.settings=true
12 | show.console.view=true
13 | show.executions.view=true
14 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | group 'com.divyanshushekhar.flutter_shortcuts'
2 | version '1.0'
3 |
4 | buildscript {
5 | repositories {
6 | google()
7 | mavenCentral()
8 | }
9 |
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:7.0.4'
12 | }
13 | }
14 |
15 | rootProject.allprojects {
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | apply plugin: 'com.android.library'
23 |
24 | android {
25 | compileSdkVersion 31
26 |
27 | defaultConfig {
28 | minSdkVersion 16
29 | }
30 | }
31 |
32 | dependencies {
33 | implementation "androidx.core:core:1.8.0-alpha02"
34 | implementation 'androidx.core:core-google-shortcuts:1.1.0-alpha01'
35 | }
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
6 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'flutter_shortcuts'
2 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/java/com/divyanshushekhar/flutter_shortcuts/FlutterShortcutsPlugin.java:
--------------------------------------------------------------------------------
1 | package com.divyanshushekhar.flutter_shortcuts;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 |
6 | import androidx.annotation.NonNull;
7 |
8 | import io.flutter.embedding.engine.plugins.FlutterPlugin;
9 | import io.flutter.embedding.engine.plugins.activity.ActivityAware;
10 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
11 | import io.flutter.plugin.common.BinaryMessenger;
12 | import io.flutter.plugin.common.MethodChannel;
13 |
14 | public class FlutterShortcutsPlugin implements FlutterPlugin, ActivityAware {
15 | private static final String CHANNEL_ID = "com.divyanshushekhar.flutter_shortcuts";
16 | private static final String TAG = "[Flutter Shortcuts]";
17 |
18 | public static String getTAG() {
19 | return TAG;
20 | }
21 |
22 | public static String getChannelId() {
23 | return CHANNEL_ID;
24 | }
25 |
26 | private MethodChannel channel;
27 | private MethodCallImplementation handler;
28 |
29 | @SuppressWarnings("deprecation")
30 | public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
31 | final FlutterShortcutsPlugin plugin = new FlutterShortcutsPlugin();
32 | plugin.setupChannel(registrar.messenger(), registrar.context(), registrar.activity());
33 | }
34 |
35 | @Override
36 | public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
37 | setupChannel(binding.getBinaryMessenger(), binding.getApplicationContext(), null);
38 | }
39 |
40 | @Override
41 | public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
42 | teardownChannel();
43 | }
44 |
45 | @Override
46 | public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
47 | handler.setActivity(binding.getActivity());
48 | }
49 |
50 | @Override
51 | public void onDetachedFromActivity() {
52 | handler.setActivity(null);
53 | }
54 |
55 | @Override
56 | public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
57 | onAttachedToActivity(binding);
58 | }
59 |
60 | @Override
61 | public void onDetachedFromActivityForConfigChanges() {
62 | onDetachedFromActivity();
63 | }
64 |
65 | private void setupChannel(BinaryMessenger messenger, Context context, Activity activity) {
66 | channel = new MethodChannel(messenger, CHANNEL_ID);
67 | handler = new MethodCallImplementation(context, activity);
68 | channel.setMethodCallHandler(handler);
69 | }
70 |
71 | private void teardownChannel() {
72 | channel.setMethodCallHandler(null);
73 | channel = null;
74 | handler = null;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/android/src/main/java/com/divyanshushekhar/flutter_shortcuts/MethodCallImplementation.java:
--------------------------------------------------------------------------------
1 | package com.divyanshushekhar.flutter_shortcuts;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Activity;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.res.AssetFileDescriptor;
8 | import android.content.res.AssetManager;
9 | import android.content.res.Resources;
10 | import android.graphics.Bitmap;
11 | import android.graphics.BitmapFactory;
12 | import android.graphics.drawable.Icon;
13 | import android.os.Build;
14 | import android.util.Log;
15 |
16 | import androidx.annotation.NonNull;
17 | import androidx.annotation.RequiresApi;
18 | import androidx.core.app.Person;
19 | import androidx.core.content.pm.ShortcutInfoCompat;
20 | import androidx.core.content.pm.ShortcutManagerCompat;
21 | import androidx.core.graphics.drawable.IconCompat;
22 |
23 | import java.io.IOException;
24 | import java.util.ArrayList;
25 | import java.util.HashMap;
26 | import java.util.List;
27 | import java.util.Map;
28 | import java.util.Objects;
29 |
30 | import io.flutter.FlutterInjector;
31 | import io.flutter.embedding.engine.loader.FlutterLoader;
32 | import io.flutter.plugin.common.MethodCall;
33 | import io.flutter.plugin.common.MethodChannel;
34 |
35 | public class MethodCallImplementation implements MethodChannel.MethodCallHandler {
36 | private static final String EXTRA_ACTION = "flutter_shortcuts";
37 | private static final String TAG = FlutterShortcutsPlugin.getTAG();
38 |
39 | private final Context context;
40 | private Activity activity;
41 |
42 | private boolean debug;
43 |
44 | void debugPrint(String message) {
45 | if(debug) {
46 | Log.d(TAG,message);
47 | }
48 | }
49 |
50 | MethodCallImplementation(Context context, Activity activity) {
51 | this.context = context;
52 | this.activity = activity;
53 | }
54 |
55 | void setActivity(Activity activity) {
56 | this.activity = activity;
57 | }
58 |
59 | @RequiresApi(api = Build.VERSION_CODES.O)
60 | @Override
61 | public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
62 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
63 | result.success(null);
64 | return;
65 | }
66 |
67 | switch (call.method) {
68 | case "initialize":
69 | initialize(call);
70 | break;
71 | case "getLaunchAction":
72 | getLaunchAction(result);
73 | break;
74 | case "getMaxShortcutLimit":
75 | result.success(getMaxShortcutLimit());
76 | break;
77 | case "getIconProperties":
78 | result.success(getIconProperties());
79 | break;
80 | case "setShortcutItems":
81 | setShortcutItems(call);
82 | break;
83 | case "pushShortcutItem":
84 | pushShortcutItem(call);
85 | break;
86 | case "pushShortcutItems":
87 | pushShortcutItems(call);
88 | break;
89 | case "updateShortcutItems":
90 | updateShortcutItems(call);
91 | break;
92 | case "updateShortcutItem":
93 | updateShortcutItem(call);
94 | break;
95 | case "changeShortcutItemIcon":
96 | changeShortcutItemIcon(call);
97 | break;
98 | case "clearShortcutItems":
99 | ShortcutManagerCompat.removeAllDynamicShortcuts(context);
100 | debugPrint("Removed all shortcuts.");
101 | break;
102 | default:
103 | result.notImplemented();
104 | break;
105 | }
106 | }
107 |
108 | private void initialize(MethodCall call) {
109 | List