Home > Enterprise >  The backgroundHandler needs to be either a static function or a top level function to be accessible
The backgroundHandler needs to be either a static function or a top level function to be accessible

Time:02-02

hey guys when I use onDidReceiveBackgroundNotificationResponse in flutter_local_notification I got an error can someone help me?

here is error

here is my code

actually I want navigate to second page after user select my notification in background mode but I got this problem

CodePudding user response:

put the definition of function used as backgroundHandler outside of any class.

ie for eg:

//if in main.dart
main(){
}

    ClassABC{
void getLetter()=>print('a and b');

}
//notice how this is outside of classABC scope and main scope.

backgroundHandler(){
// put handling code here.
}

For more clarity, could you post the whole page code? if not clear.

  • Related