How can I show a bottom sheet from an event listener?

I'm using the following code to set up a listener for share events.

import 'package:share_handler_platform_interface/share_handler_platform_interface.dart';

Future initializeShareHandler() async {
  print("init share_handler");
  final handler = ShareHandlerPlatform.instance;

  handler.sharedMediaStream.listen((SharedMedia media) {
    print("got media");
    print("content: ${media.content}");

    FFAppState().update(() => FFAppState().sharedUrl = media.content ?? "");
    // Create a bottom sheet here...
  });
}

How can I trigger a bottom sheet from here? Unfortunately, since this is being run in main.dart, I can't pass a BuildContext to it. So, I can't just create a bottom sheet.

Right now, I'm thinking about somehow triggering a global variable change (as shown above), and somehow listening to that somewhere that has access to the BuildContext.

Any ideas how I could accomplish this?

1
4 replies