diff --git a/flutter_appauth/android/src/main/java/io/crossingthestreams/flutterappauth/FlutterAppauthPlugin.java b/flutter_appauth/android/src/main/java/io/crossingthestreams/flutterappauth/FlutterAppauthPlugin.java index 93709c5e..cbec78ac 100644 --- a/flutter_appauth/android/src/main/java/io/crossingthestreams/flutterappauth/FlutterAppauthPlugin.java +++ b/flutter_appauth/android/src/main/java/io/crossingthestreams/flutterappauth/FlutterAppauthPlugin.java @@ -344,13 +344,17 @@ private void finishWithTokenError(AuthorizationException ex) { private void finishWithSuccess(Object data) { - pendingOperation.result.success(data); - pendingOperation = null; + if (pendingOperation != null) { + pendingOperation.result.success(data); + pendingOperation = null; + } } private void finishWithError(String errorCode, String errorMessage) { - pendingOperation.result.error(errorCode, errorMessage, null); - pendingOperation = null; + if (pendingOperation != null) { + pendingOperation.result.error(errorCode, errorMessage, null); + pendingOperation = null; + } } private void finishWithDiscoveryError(AuthorizationException ex) {