'I face that error when i use url lancher packege in flutter

I try to run a url using url lancher package https://pub.dev/packages/url_launcher and i got this error , i use a package to display my app over apps , using that package https://pub.dev/packages/flutter_overlay_window , and i added a button inside the overlay and when i press it it supposed to send a message to whatsapp using url lancher package , but the problem is that when your app is over apps you will get that error :

E/flutter (24166): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(NO_ACTIVITY, Launching a URL requires a foreground activity., null, null)
E/flutter (24166): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (24166): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:177:18)E/flutter (24166): <asynchronous suspension>
E/flutter (24166): #2      launchUrlString (package:url_launcher/src/url_launcher_string.dart:39:10)
E/flutter (24166): <asynchronous suspension>
E/flutter (24166): #3      launchUrl (package:url_launcher/src/url_launcher_uri.dart:57:10)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source