Skip to content

Commit 1ef7e60

Browse files
committed
Updated README.md
1 parent f8ee0fe commit 1ef7e60

File tree

2 files changed

+218
-16
lines changed

2 files changed

+218
-16
lines changed

README.md

Lines changed: 218 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,25 @@
66

77
## Show some :heart: and :star: the repo
88

9-
[![GitHub followers](https://img.shields.io/github/followers/divshekhar.svg?style=social&label=Follow)](https://github.com/divshekhar/)
9+
## Why use Flutter Shortcuts?
10+
11+
Flutter Shortcuts Plugin is known for :
12+
13+
| Flutter Shortcuts |
14+
| :--------------------------------- |
15+
| Fast, performant & compatible |
16+
| Free & Open-source |
17+
| Production ready |
18+
| Make App Reactive |
19+
20+
## Features
21+
22+
All the features listed below can be performed at the runtime.
23+
24+
&nbsp; Create Shortcuts </br>
25+
&nbsp; Clear Shortcuts </br>
26+
&nbsp; Update Shortcuts </br>
27+
&nbsp; Use both flutter and android asset as shortcut icon </br>
1028

1129
## Demo
1230

@@ -30,7 +48,9 @@ Run pub get and get packages.
3048
final FlutterShortcuts flutterShortcuts = FlutterShortcuts();
3149
```
3250

33-
### Step 3: Initialize Flutter Shortcuts
51+
## Example
52+
53+
### Define Shortcut Action
3454

3555
```dart
3656
flutterShortcuts.initialize((String incomingAction) {
@@ -42,32 +62,215 @@ flutterShortcuts.initialize((String incomingAction) {
4262
});
4363
```
4464

45-
## Arguments
65+
### Get Max Shortcut Limit
66+
67+
Return the maximum number of static and dynamic shortcuts that each launcher icon can have at a time.
68+
69+
```dart
70+
int? result = await flutterShortcuts.getMaxShortcutLimit();
71+
```
72+
73+
### Shortcut Icon Asset
74+
75+
Flutter Shortcuts allows you to create shortcut icon from both android `drawable` or `mipmap` and flutter Assets.
76+
77+
* If you want to use icon from Android resources, `drawable` or `mipmap`.
78+
79+
use: `ShortcutIconAsset.androidAsset`
80+
81+
```dart
82+
FlutterShortcutItem(
83+
id: "2",
84+
action: 'Bookmark page action',
85+
shortLabel: 'Bookmark Page',
86+
icon: "ic_launcher",
87+
shortcutIconAsset: ShortcutIconAsset.androidAsset,
88+
),
89+
```
90+
91+
* If you want to create shortcut icon from flutter asset. (DEFAULT)
92+
93+
use: `ShortcutIconAsset.flutterAsset`
94+
95+
```dart
96+
FlutterShortcutItem(
97+
id: "2",
98+
action: 'Bookmark page action',
99+
shortLabel: 'Bookmark Page',
100+
icon: 'assets/icons/bookmark.png',
101+
shortcutIconAsset: ShortcutIconAsset.flutterAsset,
102+
),
103+
```
104+
105+
### Set shortcut items
106+
107+
Publishes the list of shortcuts. All existing shortcuts will be replaced.
108+
109+
```dart
110+
flutterShortcuts.setShortcutItems(
111+
shortcutItems: <FlutterShortcutItem>[
112+
const FlutterShortcutItem(
113+
id: "1",
114+
action: 'Home page action',
115+
shortLabel: 'Home Page',
116+
icon: 'assets/icons/home.png',
117+
),
118+
const FlutterShortcutItem(
119+
id: "2",
120+
action: 'Bookmark page action',
121+
shortLabel: 'Bookmark Page',
122+
icon: "ic_launcher",
123+
shortcutIconAsset: ShortcutIconAsset.androidAsset,
124+
),
125+
],
126+
),
127+
```
128+
129+
### Clear shortcut item
130+
131+
Delete all dynamic shortcuts from the app.
132+
133+
```dart
134+
flutterShortcuts.clearShortcutItems();
135+
```
136+
137+
### Push Shortcut Item
138+
139+
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
46182

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.
48184

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();
236+
print( "maxHeight: ${result["maxHeight"]}, maxWidth: ${result["maxWidth"]}");
237+
```
60238

61239
## Project Created & Maintained By
62240

63241
### Divyanshu Shekhar
64242

65243
<a href="https://twitter.com/dshekhar17"><img src="https://github.com/aritraroy/social-icons/blob/master/twitter-icon.png?raw=true" width="60"></a> <a href="https://in.linkedin.com/in/divyanshu-shekhar-a8a04a162"><img src="https://github.com/aritraroy/social-icons/blob/master/linkedin-icon.png?raw=true" width="60"></a> <a href="https://instagram.com/dshekhar17"><img src="https://github.com/aritraroy/social-icons/blob/master/instagram-icon.png?raw=true" width="60"></a>
66244

245+
[![GitHub followers](https://img.shields.io/github/followers/divshekhar.svg?style=social&label=Follow)](https://github.com/divshekhar/)
246+
67247
### Subham Praharaj
68248

69249
<a href="https://twitter.com/SubhamPraharaj6"><img src="https://github.com/aritraroy/social-icons/blob/master/twitter-icon.png?raw=true" width="60"></a> <a href="https://www.linkedin.com/in/subham-praharaj-66b172179/"><img src="https://github.com/aritraroy/social-icons/blob/master/linkedin-icon.png?raw=true" width="60"></a> <a href="https://instagram.com/the_champ_subham_865"><img src="https://github.com/aritraroy/social-icons/blob/master/instagram-icon.png?raw=true" width="60"></a>
70250

251+
[![GitHub followers](https://img.shields.io/github/followers/thechamp865-skp.svg?style=social&label=Follow)](https://github.com/thechamp865-skp/)
252+
253+
## Contributions
254+
255+
Contributions are welcomed!
256+
257+
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+
71274
## Copyright & License
72275

73276
Code and documentation Copyright (c) 2021 [Divyanshu Shekhar](https://divyanshushekhar.com). Code released under the [BSD 3-Clause License](./LICENSE).

example/test/widget_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// gestures. You can also use WidgetTester to find child widgets in the widget
66
// tree, read text, and verify that the values of widget properties are correct.
77

8-
import 'package:flutter/material.dart';
98
import 'package:flutter_test/flutter_test.dart';
109

1110
import 'package:flutter_shortcuts_example/main.dart';

0 commit comments

Comments
 (0)