-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[path_provider] Removed pre-screening for platform #3017
Conversation
getDownloadsPath
This PR is no longer needed, since path_provider 1.6.16 perfectly works on Windows including |
The fact that it works now is just a side-effect of the implementation details of the Windows and Linux path_provider implementations; the code in question is still wrong. |
@stuartmorgan Do you want me to reopen this PR? I think my understanding of the platform handling here is somewhat limited. When is the code at |
On any platform whose implementation is based on the existing platform channels. |
OK, reopened. Then all methods of MethodChannelPathProvider should be stripped of the platform screening. |
Agreed; do you want to update the PR to do that? I can review and land it promptly if so. (It's arguably a breaking change, since the error type is changing, so doing it now while we're in nullsafety prerelease mode would be ideal.) |
OK, will do. I don't know why the test were failing the last time, since this was a very trivial change. |
…dart also fixed/reduced tests to conform to this
@stuartmorgan I am done. Please review. |
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.
I'll look into the CI failures if they repeat on the next iteration of the PR; it's not obvious to me what failed from an initial glance.
by the way, when building, these files got changed, too. Do you want me to commit them, too?
|
I don't know why the test |
Having spent more time looking at this API while doing the null-safety migration, and thinking about various error/exception cases, I'm reconsidering the approach we should take here. The current filtering is problematic because it opts platforms in, which breaks extensibility. Just removing them, however, means that instead of a clear error message when calling an unsupported method, developers will get the "no implementation found" exception. I had been thinking about that as essentially equivalent, but given how many issues come in where people see that exception and don't understand why I think that change would actually cause a lot more confusion. I don't have a great solution for this problem, unfortunately. Probably the best option, structurally, would be for each platform to have their own implementation override that throws user-friendly errors, and forwards to the method channel implementation for everything supported. However, there's not a great way to do that without Sorry for the churn on this. Let me know if you are interested in updating to that version; if not I totally understand, and can start a new PR instead. |
Dom't worry, I learned a lot doing this exercise ;-). But for future development it's probably much more efficient, if you do it. Closing this one. |
Description
I removed the checks for platforms when calling to retrieve a path.
As @stuartmorgan suggested, a plugin's platform dependent implementation should check whether the calls returns a valid result or not. So the pre-screening in the interface would be a bad practice.
Related Issues
flutter/flutter#41715
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?