diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index 8ea704b39c733..201cfcb631066 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -192,11 +192,10 @@ public void onTouch(@NonNull PlatformViewsChannel.PlatformViewTouch touch) { parsePointerCoordsList(touch.rawPointerCoords, density) .toArray(new PointerCoords[touch.pointerCount]); - View view = vdControllers.get(touch.viewId).getView(); - if (view == null) { - throw new IllegalStateException("Sending touch to an unknown view with id: " - + touch.viewId); + if (!vdControllers.containsKey(touch.viewId)) { + throw new IllegalStateException("Sending touch to an unknown view with id: " + touch.viewId); } + View view = vdControllers.get(touch.viewId).getView(); MotionEvent event = MotionEvent.obtain( touch.downTime.longValue(),