From 8308c0f5ff89f97bde8258a9b5522e1651cd4ae7 Mon Sep 17 00:00:00 2001 From: Amir Hardon Date: Tue, 25 Jun 2019 09:19:43 -0700 Subject: [PATCH] fix NPE when a touch event is sent to an unknown Android platform view --- .../flutter/plugin/platform/PlatformViewsController.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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(),