-
Notifications
You must be signed in to change notification settings - Fork 464
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
Window destroy on android and iOS #3733
base: main
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis pull request introduces a new feature that allows the application to destroy the window (exit the app) on Android and iOS platforms. The implementation checks the platform and calls the appropriate method to exit the app. Significant changes include importing necessary libraries and modifying the 'destroyWindow' function to handle mobile platforms. File-Level Changes
Tips
|
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.
Hey @bl1nch - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider using a more graceful shutdown method for iOS instead of
exit(0)
, which may not allow for proper cleanup. - The logic could be simplified by removing the redundant
isDesktop()
check and potentially adding a default case for unknown platforms.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
if (isDesktop()) { | ||
if (isDesktop() || isMobile()) { | ||
debugPrint("destroyWindow()"); |
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.
suggestion: Remove redundant platform check as all cases are handled specifically.
The isDesktop() || isMobile()
check is no longer necessary since all platforms are handled in the subsequent conditions. Consider removing this check and keeping only the debug print statement outside of any condition.
if (isDesktop()) { | |
if (isDesktop() || isMobile()) { | |
debugPrint("destroyWindow()"); | |
debugPrint("destroyWindow()"); |
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.
Hey @bl1nch - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding unit tests to ensure the window destroy functionality works correctly across all platforms.
- Using
exit(0)
for iOS might be too abrupt. Consider implementing a more graceful shutdown process that allows for proper cleanup. - Research and implement platform-specific best practices for app termination on mobile platforms to improve user experience.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
Future destroyWindow() async { | ||
if (isDesktop()) { | ||
if (isDesktop() || isMobile()) { | ||
debugPrint("destroyWindow()"); | ||
} |
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.
suggestion: Consider renaming the function to reflect its expanded functionality
The destroyWindow()
function now handles application exit for both desktop and mobile platforms. Consider renaming it to something more general like exitApplication()
or terminateApp()
to accurately reflect its broader purpose.
Future destroyWindow() async { | |
if (isDesktop()) { | |
if (isDesktop() || isMobile()) { | |
debugPrint("destroyWindow()"); | |
} | |
Future terminateApp() async { | |
if (isDesktop() || isMobile()) { | |
debugPrint("terminateApp()"); | |
} |
d602007
to
a42139f
Compare
a42139f
to
598f8c8
Compare
I have even found SystemNavigator.pop() to not always work on android, especially on google TV, exit(0) seems to be only reliable way to terminate app on android. On IOS I believe there is no way to terminate. exit(0) is next best thing there as well but should background it on that platform. In Python can terminate as well:
I find sys.exit(0) the most reliable for android/IOS, for desktop terminate3 works clean. Tried tonight using android studio with a pure flutter counter example, using my google TV streamer as test device, SystemNavigator.pop() did not work, but exit(0) successfully made android studio loose connection to device. Only other issue I have found on google TV is back button on remote crashes the flet app while home button is fine, so I submitted a PR to add predictive back support where I will call exit(0) on all platforms. |
Description
This PR should provide window destroy (app exit) function for Android and IOS platforms
Type of change
Checklist:
Summary by Sourcery
This pull request introduces a new feature that allows the application to destroy the window (exit the app) on Android and iOS platforms. The implementation checks the platform and performs the appropriate action to close the app.