Search code examples
androidflutterbackground-processflutter-workmanager

The method 'isScheduledByUniqueName' isn't defined for the type 'Workmanager'. Flutter


getting error The method 'isScheduledByUniqueName' isn't defined for the type 'Workmanager'. Try correcting the name to the name of an existing method, or defining a method named 'isScheduledByUniqueName'.dartundefined_method Type: InvalidType while using the workmanager

                    child: Text("isscheduled (Android)"),
                    onPressed: Platform.isAndroid
                        ? () async {
                            final workInfo =
                                await Workmanager().isScheduledByUniqueName(
                              simplePeriodicTask,
                            );
                            print('isscheduled = $workInfo');
                          }
                        : null),
                SizedBox(height: 8),

I have added a dependency workmanager in my projects pubspec.yaml file and also imported a package import 'package:workmanager/workmanager.dart';


Solution

  • bro i think this method Workmanager().isScheduledByUniqueName() is not define in Workmanager class.you can schedule task by this 2 methods.

    1. registerOneOffTask : for one time task
    2. registerPeriodicTask : for run task at specified interval.