Skip to content

Conversation

@vicajilau
Copy link
Collaborator

This PR implements sharedDarwinSource between iOS and macOS platforms, using the macOS implementation as the base for unified code.

Changes

  • Enabled sharedDarwinSource: true for both iOS and macOS platforms in pubspec.yaml
  • Updated iOS minimum version to iOS 14, simplifying the codebase by leveraging modern APIs (iOS 13 doesn't support PHPickerViewController and PHPickerResult)

…idating shared code for macOS and iOS. Deleted unused utility classes and updated podspec and package files to reflect changes in structure. Enhanced pubspec.yaml to enable sharedDarwinSource for iOS and macOS platforms.
class FilePickerUtils {
static func resolveType(_ type: String) -> [String] {
// Implement mapping from "audio", "image", "video", "any" to UTTypes
return []
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like it still need an implementation? Or is it unused?

let package = Package(
name: "file_picker",
platforms: [
.iOS("14.0"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you put the change to iOS 14.0 in the changelog?


public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
#if os(iOS)
self.result = result
Copy link
Collaborator

@navaronbracke navaronbracke Jan 8, 2026

Choose a reason for hiding this comment

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

This feels like the wrong place to do this? Not all methods resolve the result at a later time, in an escaping way

case "getDirectoryPath":
handleDirectorySelection(call, result: result)
case "pickFileAndDirectoryPaths":
#if os(macOS)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like how the "handlers" are just a bunch of if os() checks.
Can we follow the same pattern, where iOS / MacOS delegates to a class, that contains the handler methods?
Maybe we can do one

#if os(macOS)
  let delegate = FilePickerMacOS()
#else
  let delegate = FilePickerIOS()
#endif

and move the handlers to those methods.


// MARK: - Common Handlers

private func handleFileSelection(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@vicajilau I don't like how this file now becomes one big file with everything in it.
It makes reviewing it quite the task.

Can you create the /darwin/file_picker/Sources/file_picker folder in a separate PR,
which then also contains FilePickerUtils.swift and FilePickerMacOS.swift / FilePickerIOS.swift ?

Then I'll review those first. Afterwards, this PR will be much easier to review. (since then this PR is actually setting up the usage of the FilePickerPlugin.swift + usage of the delegates)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes @navaronbracke, it looks pretty bad. I had the same feeling as I was writing it. I'm going to come up with a new approach and I'll leave this as a draft in case I want to revise anything.

@vicajilau vicajilau marked this pull request as draft January 26, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants