Open xsahil03x opened 4 years ago
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.
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())