Skip to content

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

@xsahil03x

Description

@xsahil03x

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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions