Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: NoSuchMethodError: The method 'toRawHandle' was called on null. #30

Open
Drolegc opened this issue May 21, 2020 · 3 comments

Comments

@Drolegc
Copy link

Drolegc commented May 21, 2020

This error it shows up the first time i try to call startForegroundService, and a think this cause part of the three widgets be rebuild. For the second time, all works fine, but it seems the callback isn't getting call

The porpouse to use this plugin on my app is to check the location of the user while he/she is checking other apps, or the screen is lock.

This is what it shows on console


E/flutter (22360): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'toRawHandle' was called on null.
E/flutter (22360): Receiver: null
E/flutter (22360): Tried calling: toRawHandle()
E/flutter (22360): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (22360): #1      ForegroundService.setServiceFunction (package:foreground_service/foreground_service.dart:144:60)
E/flutter (22360): #2      ForegroundService.startForegroundService (package:foreground_service/foreground_service.dart:121:9)
E/flutter (22360): <asynchronous suspension>
E/flutter (22360): #3      ContadorGoogleMapsRepository.setForegroundService (package:easygymclub/EleccionPopular/repository/contador_google_maps_repository.dart:126:29)
E/flutter (22360): <asynchronous suspension>
E/flutter (22360): #4      ContadorGoogleMapsRepository.startTimer (package:easygymclub/EleccionPopular/repository/contador_google_maps_repository.dart:173:7)

And this is part of the code, responsable to call foreground service

debugPrint(" ### Setting foreground service ### ");
 if (await ForegroundService.foregroundServiceIsStarted())
   return;

 await ForegroundService.setServiceIntervalSeconds(1);
 await ForegroundService.setContinueRunningAfterAppKilled(false);

 await ForegroundService.notification.startEditMode();
 await ForegroundService.notification.setTitle("Easy Gym Club");
 await ForegroundService.notification.setText("Lets training!");
 await ForegroundService.notification.finishEditMode();

 await ForegroundService.startForegroundService(testFunction);
 await ForegroundService.getWakeLock();
}

Function testFunction() {
 debugPrint("#### The current time is: ${DateTime.now()}");
}

On performance mode works fine, but others mode, dont

@spalenzuela
Copy link

I have the same problem. Any solution?

@ricardopaulob
Copy link

I am having same issue. Any tips to solve this?

@Drolegc What are you mean for: "On performance mode works fine, but others mode, dont"?

@achinverma
Copy link

I am getting the same issue, Please provide the fix asap. @ricardopaulob , @spalenzuela , @Drolegc , @michael-cheung-thebus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants