Skip to content
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

fix default_plugin warnings with recent dart sdk #1567

Merged
merged 8 commits into from
Aug 6, 2024

Conversation

Sameri11
Copy link
Contributor

@Sameri11 Sameri11 commented Aug 2, 2024

This PR addresses #1555 and removes warning. Implementation is based on this comment from flutter/flutter#152037

Fixes #1484
Fixes #1483
Fixes #1343

Details:

Old implementation with default_plugin never did anything over than providing correct list of supported platforms for package page on pub.dev. Since some version of dart sdk, this behaviour has become warning.
New implementation provides (arguably) correct usage of flutter:plugins: section to avoid warning. Since all logic for choosing current platform and appropriate plugin's implementation is encapsulated inside current code, this PR just provides empty registerWith static methods needed for compilation. Also, it is mandatory for plugin implementations to be public, so we export them.

Testing:

Current tests are not affected by this PR. Example app is also functioning (tested on android and ios). Since tests on macOS (my dev machine) and example on both emulators works – I believe that functionality is not broken.

#1555 provides reproduction with https://github.com/zulip/zulip-flutter repo. This fix can be tested in that repo by adding dependency_overrides to pubspec.yaml. This override will point to my fork with fix:

dependency_overrides:
  file_picker:
    git:
      url: git@github.com:Sameri11/flutter_file_picker.git
      ref: fix-issue-1555

@Sameri11 Sameri11 marked this pull request as ready for review August 2, 2024 16:19
@Sameri11
Copy link
Contributor Author

Sameri11 commented Aug 2, 2024

Hey @miguelpruivo, @philenius can you please review this fix and/or approve workflow?

Copy link
Collaborator

@navaronbracke navaronbracke left a comment

Choose a reason for hiding this comment

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

Mainly a comment to see if we can fix a bunch of long standing issues with mis-use of Platform._operatingSystem in the plugin.

lib/src/file_picker_io.dart Outdated Show resolved Hide resolved
@OlaiyaO
Copy link

OlaiyaO commented Aug 2, 2024

I see you're all actively working on it.
I'm still experiencing the issue here.

"Package file_picker:windows references file_picker:windows as the default plugin, but it does not provide an inline implementation.
Ask the maintainers of file_picker to either avoid referencing a default implementation via platforms: windows: default_package: file_picker or add an inline implementation to file_picker via platforms: windows: pluginClass or dartPluginClass."

@navaronbracke
Copy link
Collaborator

navaronbracke commented Aug 2, 2024

I see you're all actively working on it. I'm still experiencing the issue here.

"Package file_picker:windows references file_picker:windows as the default plugin, but it does not provide an inline implementation. Ask the maintainers of file_picker to either avoid referencing a default implementation via platforms: windows: default_package: file_picker or add an inline implementation to file_picker via platforms: windows: pluginClass or dartPluginClass."

That is indeed what this PR would aim to solve yes. Once we get the required changes in this PR, I'll review it again and then we can release a fix version.

This file used before Flutter 3.3.0
@Sameri11
Copy link
Contributor Author

Sameri11 commented Aug 5, 2024

@navaronbracke can you please take another look at this? I think I implemented what you talked about here.

Btw, I had hard times reproducing #1343 both based on this PR and master – no success. Either I do something wrong, or, maybe, these issues were fixed earlier somehow.

Copy link
Collaborator

@navaronbracke navaronbracke left a comment

Choose a reason for hiding this comment

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

Overall this looks good, just some small documentation suggestions.

Once those are addressed, we can land this!

export './src/file_picker_io.dart';
// Conditional export needed for web to successfully compile.
export './src/windows/file_picker_windows_stub.dart'
if (dart.library.ffi) './src/windows/file_picker_windows_real.dart';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we keep the file_picker_windows.dart filename for the real implementation? (rather than file_picker_windows_real.dart)
The fact that the fake one is called file_picker_windows_stub.dart clarifies its use in my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have no strong opinion about this. So yes, done :)

lib/file_picker.dart Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
@navaronbracke
Copy link
Collaborator

I also edited the original PR comment to list fixed issues, so these get closed when the PR is merged.

As for not being able to reproduce #1343 I'm not sure either.

Sameri11 and others added 2 commits August 6, 2024 22:07
Co-authored-by: Navaron Bracke <brackenavaron@gmail.com>
Co-authored-by: Navaron Bracke <brackenavaron@gmail.com>
Copy link
Collaborator

@navaronbracke navaronbracke left a comment

Choose a reason for hiding this comment

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

LGTM!

I also edited out the redundant bullet points (one was an implementation detail, which users don't care about and the other was now a duplicate point since we already mention fixing #1555 in the first point)

@navaronbracke
Copy link
Collaborator

navaronbracke commented Aug 6, 2024

It looks like one of the test is failing, because https://github.com/miguelpruivo/flutter_file_picker/pull/1561/files did not update a test expectation.

This commit fixes a test expectation that was not updated in a previous PR.
@navaronbracke navaronbracke merged commit d7f3669 into miguelpruivo:master Aug 6, 2024
3 checks passed
@navaronbracke
Copy link
Collaborator

Checks are green, so ship it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants