-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[url_launcher] Update for UIScene compatibility #10549
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
[url_launcher] Update for UIScene compatibility #10549
Conversation
Replaces the code that attempted to find the topmost presented view controller as the context for presenting a Safari view controller with a call to the new registrar API to get the Flutter view's controller. Since it's now possible for there not to be a view controller, adds an exception for that case. This should only be possible in an add-to-app scenario where someone tries to show an in-app URL from a Flutter view that is not being displayed, which is an unlikely enough scenario that I'm not going to consider this a breaking change. Fixes flutter/flutter#174415
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.
This is copied directly from the recent file_selector_ios PR to adopt UIScene, since we have the same DI needs here.
| /// a stub implementation of FlutterPluginRegistrar for tests would break any time something was | ||
| /// added to that protocol. | ||
| protocol ViewPresenterProvider { | ||
| /// Returns the view controller associated with the Flutter content. |
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.
nit: Returns the view presenter [...]
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.
Fixed.
| private var currentSession: URLLaunchSession? | ||
| private let launcher: Launcher | ||
| /// The view controller provider, for showing a Safari view controller. | ||
| private let viewPresenterProvider: ViewPresenterProvider |
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.
The view controller provider
Should we call this a ViewControllerPresenterProvider then?
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.
Changed to "The view presenter provider". Because it's just a testability abstraction around a view controller it was hard not to default to calling it a view controller.
| } | ||
| } | ||
|
|
||
| final class StubViewPresenterProvider: ViewPresenterProvider { |
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.
Shall we use the same prefix "Test-" above and "Stub-" here?
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.
They don't do the same things; StubViewPresenterProvider is a stub, in that it just returns a fixed value, while TestViewPresenter tracks calls and updates its state (more like a mock).
| @@ -1,3 +1,8 @@ | |||
| ## 6.4.0 | |||
|
|
|||
| * Improves compatibility with `UIScene`. | |||
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.
This refers to the removal of UIApplication.shared.keyWindow?.rootViewController?.topViewController right?
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.
Correct, that's the substantive change here; the rest is testability.
flutter/packages@8cb4903...d39e481 2025-12-04 [email protected] [pigeon] Fixes crash that occurs when an object that is removed from the instance manager calls to Dart (flutter/packages#10552) 2025-12-04 [email protected] [pigeon] Fixes error from constructor parameter sharing name with attached field for a ProxyApi (flutter/packages#10541) 2025-12-04 [email protected] fix[image_picker_ios]: Prevent transcoding on video selection (flutter/packages#10559) 2025-12-04 [email protected] [webview_flutter_wkwebview] Fixes crash when running `WKNavigationResponse` tests on Xcode 26 (flutter/packages#10316) 2025-12-03 [email protected] Redistribute iOS CODEOWNERS (flutter/packages#10520) 2025-12-03 [email protected] [url_launcher] Update for UIScene compatibility (flutter/packages#10549) 2025-12-03 [email protected] Roll Flutter from e274574 to 69d8710 (5 revisions) (flutter/packages#10558) 2025-12-03 [email protected] Roll Flutter from 5545bb3 to e274574 (17 revisions) (flutter/packages#10554) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Replaces the code that attempted to find the topmost presented view controller as the context for presenting a Safari view controller with a call to the new registrar API to get the Flutter view's controller.
Since it's now possible for there not to be a view controller, adds an exception for that case. This should only be possible in an add-to-app scenario where someone tries to show an in-app URL from a Flutter view that is not being displayed, which is an unlikely enough scenario that I'm not going to consider this a breaking change.
Fixes flutter/flutter#174415
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3