If the flutter app is actually running you can access the context via a navigatorKey
on the MaterialApp
. Note that the function you are referring to needs to be in the dart side in the flutter app.
final navigatorKey = GlobalKey<NavigatorState>();
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: navigatorKey
);
}
Then in the flutter function you can gain access to the context by navigatorKey.currentState.context
or navigatorKey.currentState.overlay.context
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…