-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an event stream to communicate with Android's native end #282
Conversation
… an event stream to report payment status updates back to the widgets and those that operate synchronously Update Google Pay button to use an event stream and avoid lifecycle issues
…ication and additional information on the readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some suggestion but in general LGTM!
pay_android/android/src/main/kotlin/io/flutter/plugins/pay_android/PayMethodCallHandler.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Is there a specific aspect here you wanted me to review? I'm not familiar with this codebase or its public API surface, so I can't provide much input on the overall design. |
This addresses the issue we discussed about the native end of a plugin losing track of result objects (to report back to the dart end) when an activity on Android is recycled/destroyed before a result is returned. An event stream that subscribes at activity [re]creation time is present and ready to return results back to Flutter even in situations when the forefront activity is destroyed. Concretely, it'd be valuable to get your thoughts on the solution proposed. Key files are:
|
By the way, @JlUgia, we performed some tests based on this branch on our side and resolved the issue you mentioned in the description. LGTM! |
This change adds functionality to allow diverse communications channels between the platforms supported.
The existing relationship between Android's activity lifecycle and the Flutter engine is loose, and activity recreation events (for activity-aware plugins) re-creates the engine and all its bindings (e.g.: the data channel between the native and dart ends). There's been proposals to circumvent this limitation (see
image_picker
's proposal). This approach prefers to open up a channel between Flutter and the native end as soon as the widget is added to the tree, such that, if the main activity hosting the widget's action is destroyed, the new instance will pick up from where the last left.This fixes #277, #274, #261, #206, and addresses #278 and #276.
The change includes: