@@ -34,139 +34,174 @@ class _MyAppState extends State<MyApp> {
3434 appBar: AppBar (
3535 title: const Text ('Flutter Shortcuts Plugin' ),
3636 ),
37- body: Column (
38- children: [
39- Center (
40- child: Text ('ShortcutItem action : $action \n ' ),
41- ),
42- ElevatedButton (
43- child: Text ("Set Shortcuts" ),
44- onPressed: () async {
45- await flutterShortcuts.setShortcutItems (
46- shortcutItems: < FlutterShortcutItem > [
37+ body: SingleChildScrollView (
38+ child: Column (
39+ children: [
40+ Center (
41+ child: Text ('ShortcutItem action : $action \n ' ),
42+ ),
43+ ElevatedButton (
44+ child: Text ("Get Max Shortcut Limit" ),
45+ onPressed: () async {
46+ int result = await flutterShortcuts.getMaxShortcutLimit ();
47+ print ("======> max: $result " );
48+ },
49+ ),
50+ ElevatedButton (
51+ child: Text ("Set Shortcuts" ),
52+ onPressed: () async {
53+ await flutterShortcuts.setShortcutItems (
54+ shortcutItems: < FlutterShortcutItem > [
55+ const FlutterShortcutItem (
56+ id: "1" ,
57+ action: 'Homepage' ,
58+ shortLabel: 'Play Ludo' ,
59+ icon: 'ic_launcher' ,
60+ ),
61+ const FlutterShortcutItem (
62+ id: "2" ,
63+ action: 'Secondpage' ,
64+ shortLabel: 'Play Snake Ladder' ,
65+ icon: 'ic_launcher' ,
66+ ),
67+ ],
68+ ).then ((value) {
69+ setState (() {
70+ if (action == 'No Action' ) {
71+ action = 'Flutter Shortcuts Ready' ;
72+ }
73+ });
74+ });
75+ },
76+ ),
77+ ElevatedButton (
78+ child: Text ("Clear All Shortcuts" ),
79+ onPressed: () {
80+ flutterShortcuts.clearShortcutItems ();
81+ },
82+ ),
83+ ElevatedButton (
84+ child: Text ("push Shortcut Item" ),
85+ onPressed: () async {
86+ await flutterShortcuts.pushShortcutItem (
87+ shortcut: FlutterShortcutItem (
88+ id: "2" ,
89+ action: "fifthaction" ,
90+ shortLabel: "shortLabel" ,
91+ ),
92+ );
93+ },
94+ ),
95+ ElevatedButton (
96+ child: Text ("Update all shortcuts" ),
97+ onPressed: () async {
98+ await flutterShortcuts.updateAllShortcutItems (
99+ shortcutList: < FlutterShortcutItem > [
100+ const FlutterShortcutItem (
101+ id: "1" ,
102+ action: 'Homepage' ,
103+ shortLabel: 'Home Page 1' ,
104+ icon: 'ic_launcher' ,
105+ ),
106+ const FlutterShortcutItem (
107+ id: "2" ,
108+ action: 'Secondpage' ,
109+ shortLabel: 'Second Page 2' ,
110+ icon: 'ic_launcher' ,
111+ ),
112+ ]);
113+ },
114+ ),
115+ ElevatedButton (
116+ child: Text ("Update and add New shortcuts" ),
117+ onPressed: () async {
118+ await flutterShortcuts
119+ .addShortcutItems (shortcutList: < FlutterShortcutItem > [
47120 const FlutterShortcutItem (
48121 id: "1" ,
49122 action: 'Homepage' ,
50- shortLabel: 'Play Ludo ' ,
123+ shortLabel: 'Home Page 1 ' ,
51124 icon: 'ic_launcher' ,
52125 ),
53126 const FlutterShortcutItem (
54127 id: "2" ,
55128 action: 'Secondpage' ,
56- shortLabel: 'Play Snake Ladder ' ,
129+ shortLabel: 'Second Page 2 ' ,
57130 icon: 'ic_launcher' ,
58131 ),
59- ],
60- ).then ((value) {
61- setState (() {
62- if (action == 'No Action' ) {
63- action = 'Flutter Shortcuts Ready' ;
64- }
65- });
66- });
67- },
68- ),
69- ElevatedButton (
70- child: Text ("Clear All Shortcuts" ),
71- onPressed: () {
72- flutterShortcuts.clearShortcutItems ();
73- },
74- ),
75- ElevatedButton (
76- child: Text ("push Shortcut Item" ),
77- onPressed: () async {
78- await flutterShortcuts.pushShortcutItem (
79- shortcut: FlutterShortcutItem (
80- id: "5" ,
81- action: "fifthaction" ,
82- shortLabel: "shortLabel" ,
83- ),
84- );
85- },
86- ),
87- ElevatedButton (
88- child: Text ("Update all shortcuts" ),
89- onPressed: () async {
90- await flutterShortcuts
91- .updateAllShortcutItems (shortcutList: < FlutterShortcutItem > [
92- const FlutterShortcutItem (
93- id: "1" ,
94- action: 'Homepage' ,
95- shortLabel: 'Home Page 1' ,
96- icon: 'ic_launcher' ,
97- ),
98- const FlutterShortcutItem (
99- id: "2" ,
100- action: 'Secondpage' ,
101- shortLabel: 'Second Page 1' ,
102- icon: 'ic_launcher' ,
103- ),
104- ]);
105- },
106- ),
107- ElevatedButton (
108- child: Text ("Update 2nd Shortcut" ),
109- onPressed: () {
110- flutterShortcuts.updateShortcutItem (
111- id: "1" ,
112- shortcut: FlutterShortcutItem (
132+ const FlutterShortcutItem (
133+ id: "3" ,
134+ action: 'Thirdpage' ,
135+ shortLabel: 'Third Page 3' ,
136+ icon: 'ic_launcher' ,
137+ ),
138+ ]);
139+ },
140+ ),
141+ ElevatedButton (
142+ child: Text ("Update 2nd Shortcut" ),
143+ onPressed: () {
144+ flutterShortcuts.updateShortcutItem (
113145 id: "1" ,
114- action: 'Fourthpage' ,
115- shortLabel: 'Fourth Page 4' ,
116- icon: 'ic_launcher' ,
117- ),
118- );
119- },
120- ),
121- ElevatedButton (
122- child: Text ("Change icon of 2nd Shortcut" ),
123- onPressed: () {
124- flutterShortcuts.changeShortcutItemIcon (
125- id: "2" , icon: "bookmark_icon" );
126- },
127- ),
128- ElevatedButton (
129- child: Text ("change icon color of 2nd Shortcut" ),
130- onPressed: () {
131- // disable title
132- // flutterShortcuts.changeIconColor(id, color);
133- },
134- ),
135- ElevatedButton (
136- child: Text ("change icon backgroud color of 2nd Shortcut" ),
137- onPressed: () {
138- // disable title
139- // flutterShortcuts.changeIconBackgroundColor(id, color);
140- },
141- ),
142- ElevatedButton (
143- child: Text ("set animated icon of 2nd Shortcut" ),
144- onPressed: () {
145- // disable title
146- // flutterShortcuts.setAnimatedIcon(id, AnimatedIcon);
147- },
148- ),
149- ElevatedButton (
150- child: Text ("set icon backgroud gradient of 2nd Shortcut" ),
151- onPressed: () {
152- // disable title
153- // flutterShortcuts.iconBackgroundGradient(id,[start,end], [start color,end color]);
154- },
155- ),
156- ElevatedButton (
157- child: Text ("Change title of 2nd Shortcut" ),
158- onPressed: () {
159- // flutterShortcuts.updateShortcutItemTitle(id, title);
160- },
161- ),
162- ElevatedButton (
163- child: Text ("Toggle disable state of 2nd Shortcut" ),
164- onPressed: () {
165- // disable title
166- // flutterShortcuts.updateDisableStateShortcutItem(id, state(bool), disable title);
167- },
168- ),
169- ],
146+ shortcut: FlutterShortcutItem (
147+ id: "1" ,
148+ action: 'Fourthpage' ,
149+ shortLabel: 'Fourth Page 4' ,
150+ icon: 'ic_launcher' ,
151+ ),
152+ );
153+ },
154+ ),
155+ ElevatedButton (
156+ child: Text ("Change icon of 2nd Shortcut" ),
157+ onPressed: () {
158+ flutterShortcuts.changeShortcutItemIcon (
159+ id: "2" , icon: "bookmark_icon" );
160+ },
161+ ),
162+ ElevatedButton (
163+ child: Text ("change icon color of 2nd Shortcut" ),
164+ onPressed: () {
165+ // disable title
166+ // flutterShortcuts.changeIconColor(id, color);
167+ },
168+ ),
169+ ElevatedButton (
170+ child: Text ("change icon backgroud color of 2nd Shortcut" ),
171+ onPressed: () {
172+ // disable title
173+ // flutterShortcuts.changeIconBackgroundColor(id, color);
174+ },
175+ ),
176+ ElevatedButton (
177+ child: Text ("set animated icon of 2nd Shortcut" ),
178+ onPressed: () {
179+ // disable title
180+ // flutterShortcuts.setAnimatedIcon(id, AnimatedIcon);
181+ },
182+ ),
183+ ElevatedButton (
184+ child: Text ("set icon backgroud gradient of 2nd Shortcut" ),
185+ onPressed: () {
186+ // disable title
187+ // flutterShortcuts.iconBackgroundGradient(id,[start,end], [start color,end color]);
188+ },
189+ ),
190+ ElevatedButton (
191+ child: Text ("Change title of 2nd Shortcut" ),
192+ onPressed: () {
193+ // flutterShortcuts.updateShortcutItemTitle(id, title);
194+ },
195+ ),
196+ ElevatedButton (
197+ child: Text ("Toggle disable state of 2nd Shortcut" ),
198+ onPressed: () {
199+ // disable title
200+ // flutterShortcuts.updateDisableStateShortcutItem(id, state(bool), disable title);
201+ },
202+ ),
203+ ],
204+ ),
170205 ),
171206 ),
172207 );
0 commit comments