Closed
Description
Steps to Reproduce
I wanna jump to other viewController by Plugin in Flutter, however, i met a problem: the FlutterViewController can receive gesture events from other viewController.
this is my demo link: https://github.com/helang1991/flutter_iOS_gesture_demo
Logs
Reloaded 1 of 441 libraries in 502ms.
flutter: I received gesture events in FlutterViewController
flutter: I received gesture events in FlutterViewController
flutter: I received gesture events in FlutterViewController
flutter: I received gesture events in FlutterViewController
flutter: I received gesture events in FlutterViewController
flutter: I received gesture events in FlutterViewController
flutter: I received gesture events in FlutterViewController
flutter: I received gesture events in FlutterViewController
flutter: I received gesture events in FlutterViewController
[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.5 18F132, locale
en-CN)
• Flutter version 1.5.4-hotfix.2 at /Users/helang/Flutter/flutter
• Framework revision 7a4c33425d (2 months ago), 2019-04-29 11:05:24 -0700
• Engine revision 52c7a1e849
• Dart version 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/helang/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/helang/Library/Android/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1343-b01)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[!] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
✗ libimobiledevice and ideviceinstaller are not installed. To install with
Brew, run:
brew update
brew install --HEAD usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
brew install ideviceinstaller
✗ ios-deploy not installed. To install:
brew install ios-deploy
• CocoaPods version 1.6.1
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 37.0.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1343-b01)
[✓] Connected device (1 available)
• iPhone Xʀ • 72F8738C-7190-48B4-956C-50A0DE6B74BC • ios •
com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)
! Doctor found issues in 3 categories.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
Piinks commentedon Jul 9, 2019
Hi @helang1991, can you post a reproduction of the issue as well as the output of
flutter doctor
? We will need more information to help you resolve it.helang1991 commentedon Jul 10, 2019
Hi @Piinks ,I clicked screen in other viewController by plugin, why the FlutterViewController received gesture events? Maybe other developers made similar issue.
crackerli commentedon Jul 10, 2019
I also met the problem, from the beginning, I want to develop a customized camera, a new plugin is developed to achieve this, the customized camera is a native page, when I open the camera page from flutter button, then there are two pages in app, foreground native camera page and background flutter page, something bad happened here were that when I click on the native camera page, the background futter page can receive the click event, eg. some button can react to these events.
Til now, I found the issue can be reproduced only in ios platform, android works well.
I found that image_picker have the same issue, please refer this link below:
#32896
Further more, to find the root cause, I replace the camera native page with one common native page of ios, this issue can be produced too
crackerli commentedon Jul 17, 2019
Any update on this issue? @Piinks Piinks
maeharin commentedon Jul 30, 2019
I encountered the same problem. Here is my investigation and current workaround.
Sample application
https://github.com/maeharin/flutter_ios_present_sample
Screenshot
Why this occured
Looking at the implementation of FlutterViewController (ex: engine v1.5.4-hotfixes branch), we can see they are overriding 4 methods(such as the touchesBegan). From here, the iOS touch event is propagated to the Flutter side
https://github.com/flutter/engine/blob/v1.5.4-hotfixes/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm#L649-L663
See the apple documentation below for how to call touchesBegan. Touch events on the iOS side are designed to run up the Responder Chain
https://developer.apple.com/documentation/uikit/touches_presses_and_gestures/using_responders_and_the_responder_chain_to_handle_events
In our case, Responder Chain is like this
Workaround
The following workarounds can be considered
1. Override 4 methods of UIViewController that is presented from FlutterViewController
This prevents propagating unhandled events to FlutterViewController
2. Stop doing present from FlutterViewController
Do not present() the UIViewController directly from the FlutterViewController, for example, by making the iOS side rootViewController a NavigationController instead of a FlutterViewController.
This article will be helpful for how to change rootViewController
https://medium.com/@najeira/change-ios-rootviewcontroller-with-flutter-fc4234f37105
helang1991 commentedon Jul 30, 2019
Thanks for your advice, I'll try your methods to fix it
iapicca commentedon Mar 16, 2020
Hi @helang1991
if the issue persist with the latest stable version of flutter
could you please provide your updated
flutter doctor -v
,your
flutter run --verbose
and if possible a reproducible minimal code sample.
Thank you
7 remaining items