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

registrar.activity() returns null when used with Flutter's background execution feature. #31

Open
xsahil03x opened this issue Jan 3, 2020 · 1 comment

Comments

@xsahil03x
Copy link

Flutter's new background execution feature (described here: https://medium.com/flutter-io/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124) allows plugins to be registered in a background context (e.g. a Service). The problem is that the flutter_webview plugin assumes that the context for plugin registration is an activity with this line of code:

val plugin = FlutterWebViewPlugin(registrar.activity())

registrar.activity() may now return null, and this leads to a NullPointerException:

The solution is to change the above line of code to this:

val plugin = FlutterWebViewPlugin(registrar.activeContext())

@rlee1990
Copy link

This is needed as must plugins no longer need
class MainActivity: FlutterActivity() { override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { GeneratedPluginRegistrant.registerWith(flutterEngine); } }

and will not run with it and this plugin won't run without it.

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

2 participants