You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
140
+
141
+
```dart
142
+
flutterShortcuts.pushShortcutItem(
143
+
shortcut: FlutterShortcutItem(
144
+
id: "5",
145
+
action: "Play Music Action",
146
+
shortLabel: "Play Music",
147
+
icon: 'assets/icons/music.png',
148
+
),
149
+
);
150
+
```
151
+
152
+
### Push Shortcut Items
153
+
154
+
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.
155
+
156
+
```dart
157
+
flutterShortcuts.pushShortcutItems(
158
+
shortcutList: <FlutterShortcutItem>[
159
+
const FlutterShortcutItem(
160
+
id: "1",
161
+
action: 'Home page new action',
162
+
shortLabel: 'Home Page',
163
+
icon: 'assets/icons/home.png',
164
+
),
165
+
const FlutterShortcutItem(
166
+
id: "2",
167
+
action: 'Bookmark page new action',
168
+
shortLabel: 'Bookmark Page',
169
+
icon: 'assets/icons/bookmark.png',
170
+
),
171
+
const FlutterShortcutItem(
172
+
id: "3",
173
+
action: 'Settings Action',
174
+
shortLabel: 'Setting',
175
+
icon: 'assets/icons/settings.png',
176
+
),
177
+
],
178
+
);
179
+
```
180
+
181
+
### Update Shortcut Item
46
182
47
-
There are several function that allow for more control:
183
+
Updates a single shortcut item based on id. If the ID of the shortcut is not same, no changes will be reflected.
48
184
49
-
| Properties | Description |
50
-
|--------------|-----------------|
51
-
|`initialize`| performs action when shortcut is initiated.|
52
-
|`getMaxShortcutLimit`| returns the maximum number of static or dynamic shortcuts that each launcher icon can have at a time. |
53
-
|`setShortcutItems`| will set all the shortcut items. |
54
-
|`clearShortcutItems`| will remove all the shortcut items.|
55
-
|`pushShortcutItem`| will 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. |
56
-
|`addShortcutItems`|updates dynamic or pinned shortcuts with same IDs and pushes new shortcuts with different IDs. |
57
-
|`updateShortcutItems`| updates shortcut items. If the IDs of the shortcuts are not same, no changes will be reflected. |
58
-
|`updateShortcutItem`| updates a single shortcut item based on id. If the ID of the shortcut is not same, no changes will be reflected. |
59
-
|`changeShortcutItemIcon`| will change the icon of the shortcut based on id.s If the ID of the shortcut is not same, no changes will be reflected. |
185
+
```dart
186
+
flutterShortcuts.updateShortcutItem(
187
+
shortcut: FlutterShortcutItem(
188
+
id: "1",
189
+
action: 'Go to url action',
190
+
shortLabel: 'Visit Page',
191
+
icon: 'assets/icons/url.png',
192
+
),
193
+
);
194
+
```
195
+
196
+
### Update Shortcut Items
197
+
198
+
Updates shortcut items. If the IDs of the shortcuts are not same, no changes will be reflected.
199
+
200
+
```dart
201
+
flutterShortcuts.updateShortcutItems(
202
+
shortcutList: <FlutterShortcutItem>[
203
+
const FlutterShortcutItem(
204
+
id: "1",
205
+
action: 'Resume playing Action',
206
+
shortLabel: 'Resume playing',
207
+
icon: 'assets/icons/play.png',
208
+
),
209
+
const FlutterShortcutItem(
210
+
id: "2",
211
+
action: 'Search Songs Action',
212
+
shortLabel: 'Search Songs',
213
+
icon: 'assets/icons/search.png',
214
+
),
215
+
],
216
+
);
217
+
```
218
+
219
+
### Change Shortcut Item Icon
220
+
221
+
Change the icon of the shortcut based on id. If the ID of the shortcut is not same, no changes will be reflected.
222
+
223
+
```dart
224
+
flutterShortcuts.changeShortcutItemIcon(
225
+
id: "2",
226
+
icon: "assets/icons/next.png",
227
+
);
228
+
```
229
+
230
+
### Get shortcut icon properties
231
+
232
+
Get the icon properties of your shortcut icon.
233
+
234
+
```dart
235
+
Map<String, int> result = await flutterShortcuts.getIconProperties();
If you feel that a hook is missing, feel free to open a pull-request.
258
+
259
+
For a custom-hook to be merged, you will need to do the following:
260
+
261
+
Describe the use-case.
262
+
263
+
* Open an issue explaining why we need this hook, how to use it, ...
264
+
This is important as a hook will not get merged if the hook doens't appeal to
265
+
a large number of people.
266
+
267
+
* If your hook is rejected, don't worry! A rejection doesn't mean that it won't
268
+
be merged later in the future if more people shows an interest in it.
269
+
In the mean-time, feel free to publish your hook as a package on https://pub.dev.
270
+
271
+
* A hook will not be merged unles fully tested, to avoid breaking it inadvertendly
272
+
in the future.
273
+
71
274
## Copyright & License
72
275
73
276
Code and documentation Copyright (c) 2021 [Divyanshu Shekhar](https://divyanshushekhar.com). Code released under the [BSD 3-Clause License](./LICENSE).
0 commit comments