Skip to content

Conversation

@stuartmorgan-g
Copy link
Collaborator

Switches from the global window's view controller to the view controller provided by the new FlutterPluginRegistrar viewController method.

Updates minimum Flutter version to 3.38 for the new API used.

Fixes flutter/flutter#174419

Pre-Review Checklist

Footnotes

  1. 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

Switches from the global window's view controller to the view controller
provided by the new FlutterPluginRegistrar `viewController` method.

Updates minimum Flutter version to 3.38 for the new API used.

Fixes flutter/flutter#174419
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully migrates the file_selector_ios plugin to be compatible with UIScene by using the viewController from FlutterPluginRegistrar instead of relying on the application's key window. The implementation uses dependency injection by introducing a ViewPresenterProvider protocol, which improves testability and modernizes the codebase. The related tests and SDK version constraints have been updated accordingly. The changes are well-implemented, but I have a few minor suggestions to improve code style and documentation consistency.

documentPicker.delegate = completionBridge

let presenter =
self.viewPresenterOverride ?? UIApplication.shared.delegate?.window??.rootViewController
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could keep this override structure instead of adding ViewPresenterProvider, but I thought it was cleaner to reduce test branching in production code.

}

/// Non-test implementation of ViewControllerProvider that forwards to the plugin registrar.
class DefaultViewPresenterProvider: ViewPresenterProvider {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary because FlutterPluginRegistrar is a protocol rather than a class, and the Swift "One Weird Trick" to add protocol conformance only works on classes, not protocols, so we can't do a no-code passthrough to the real registrar using something like line 21 above.

@stuartmorgan-g
Copy link
Collaborator Author

ViewPresenter.swift:42:15: error: value of type 'any FlutterPluginRegistrar' has no member 'viewController'

Ah right, landing any of these changes is going to require publishing a new Flutter pod. @vashworth Do you have the instructions for that, or do I need to try to dig them out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[file_selector_ios][UIScene] Migrate to scene APIs

1 participant