Skip to content

Commit 2578247

Browse files
authored
#166 Fix ClassCastException on Android (#196)
Due to Dart not always transporting the callback handle as a `long` the forced cast to `Long` on Android fails if the handle is only an `int`. Props to @mbabker for finding this out. As a solution, the number is cast to `Number` instead. The actual value can still be extracted as a `long`.
1 parent 874f6a4 commit 2578247

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

android/src/main/java/com/bluechilli/flutteruploader/MethodCallHandlerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ public void onMethodCall(MethodCall call, @NonNull Result result) {
7777
}
7878

7979
void setBackgroundHandler(MethodCall call, MethodChannel.Result result) {
80-
Long callbackHandle = call.argument("callbackHandle");
80+
Number callbackHandle = call.argument("callbackHandle");
8181
if (callbackHandle != null) {
82-
SharedPreferenceHelper.saveCallbackDispatcherHandleKey(context, callbackHandle);
82+
SharedPreferenceHelper.saveCallbackDispatcherHandleKey(context, callbackHandle.longValue());
8383
}
8484

8585
result.success(null);

0 commit comments

Comments
 (0)