-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[image_picker] Added image_picker_for_windows. #4863
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
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.
Looks good! This will need Dart unit tests that sets a mock FileSelectorPlatform
implementation as FileSelectorPlatform.instance
and validates that the expected calls are made. And also that registerWith
works (as in other Dart plugin implementation tests).
While the logic is currently pretty trivial, having tests in place is important as we change it over time.
packages/image_picker/image_picker_for_windows/example/lib/main.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_for_windows/example/lib/main.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_for_windows/lib/image_picker_for_windows.dart
Outdated
Show resolved
Hide resolved
I believe I got it all. Let me know if there is anything missing. |
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.
Just a few more minor things, sorry I missed some of these on the first review. Thanks for implementing this!
Adding @cbracken for secondary review.
packages/image_picker/image_picker_windows/example/lib/main.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_windows/example/lib/main.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Outdated
Show resolved
Hide resolved
d5e2767
to
59b831d
Compare
Oh, I believe I need to add the image_picker_windows to the exclude_integration_win32.yaml file. |
@stuartmorgan anything else needed here? |
Sorry for the slow response, I haven't had much time for reviews because of the build issue with VS 17.1.0. |
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.
A few other small things, but otherwise it should be good from my side.
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Outdated
Show resolved
Hide resolved
expect( | ||
log, | ||
<Matcher>[ | ||
isMethodCall('openFile', arguments: <String, dynamic>{ |
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.
You are testing implementation details of file_selector
here; these tests would all break if FileSelectorWindows changed its implementation (e.g., switched to a Dart implementation, or to using Pigeon).
Even though you can't use FileSelectorPlatform.instance
in the implementation, you can still write the implementation against a FileSelectorPlatform
variable, and just manually instantiate it with a FileSelectorWindows
. Then you can make that instance settable by tests, and insert a mock implementation in these tests and validate against that mock. Then it doesn't matter how FileSelectorWindows
works, because you'll just be verifying that you're using its API correctly.
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.
@stuartmorgan I just pushed the changes. I believe that is what you means, which I agree that is a way better approach.
@stuartmorgan anything needed 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.
One comment about adding a few more tests, but LGTM otherwise. The main thing this is waiting on is just the second review from @cbracken.
packages/image_picker/image_picker_windows/test/image_picker_windows_test.dart
Show resolved
Hide resolved
@cbracken anything else needed here? |
Merged main into this branch just to keep it up to date. |
Merged main again, just to keep this updated. Unlike the local_auth plugin, the image_picker plugin is already federated. @stuartmorgan / @cbracken what is keeping this PR from being reviewed/merged? |
It's still @cbracken having time to review; Flutter policy requires two reviews for PRs from people outside the org before landing. |
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.
Overall looks good! Just a few comments.
await _playVideo(file); | ||
} else if (isMultiImage) { | ||
await _displayPickImageDialog(context!, | ||
(double? maxWidth, double? maxHeight, int? quality) async { |
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.
Optionally, consider breaking this out to a separate private method like _handleMultiImagePicked
to reduce the amount of handling directly under _onImageButtonPressed
.
}); | ||
} else { | ||
await _displayPickImageDialog(context!, | ||
(double? maxWidth, double? maxHeight, int? quality) async { |
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.
Similar comment here; something like _handleSingleImagePicked
.
} | ||
|
||
dynamic _pickImageError; | ||
bool isVideo = false; |
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.
Consider making this private.
bool isVideo = false; | ||
|
||
VideoPlayerController? _controller; | ||
VideoPlayerController? _toBeDisposed; |
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.
Since there's a little complexity around the use of this field, add a doc comment explaining how it's used.
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_windows/lib/image_picker_windows.dart
Show resolved
Hide resolved
@cbracken let me know what you think. |
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 PR adds a very simplistic Windows implementation of the image_picker plugin, which uses the file_selector plugin to get images or videos from the "gallery". This initial implementation doesn't yet support ImageSource.camera (falls back to gallery).
Fixes flutter/flutter#92108
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).