Djamila Jada
Djamila Jada

Reputation: 151

how to run code dart on click app icon without launching the app

i am trying to develop an flutter app that when i click on the app icon a task will start without launching the app , i find the package quick action but when i click on the quick action always app is launched this is my code

 import 'package:flutter/material.dart';
 import 'package:quick_actions/quick_actions.dart';

 void main() {
     WidgetsFlutterBinding.ensureInitialized();
     final QuickActions quickActions = QuickActions();

     quickActions.initialize((shortcutType) {
       if (shortcutType == 'action_one') {
          print('The user tapped on the "Main view" action.');
       }
     });

     quickActions.setShortcutItems(<ShortcutItem>[
       const ShortcutItem(
         type: 'action_one',
         localizedTitle: 'Action one',
         icon: 'AppIcon',
         ),
       const ShortcutItem(
         type: 'action_two', localizedTitle: 'Action two', icon: 'ic_launcher'),
       ]);
   //runApp(MyApp());<-- comment
   }

thank you for helping me

Upvotes: 1

Views: 216

Answers (1)

Vishwesh Soni
Vishwesh Soni

Reputation: 101

I think you are doing only one click,
you have to tap long on the app ,
Also check const is missing there.

final QuickActions quickActions = const QuickActions();

Upvotes: 0

Related Questions