-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera] Add implementations for camera_platform_interface
package.
#3302
[camera] Add implementations for camera_platform_interface
package.
#3302
Conversation
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent. |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
1 similar comment
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent. |
(I've published camera_platform_interface, sorry for the delay!) |
Nice! The dependency should now be updated as well. |
906720a
to
4778ad0
Compare
Hey @BeMacized @mvanbeusekom, can you edit this PR so I'm allowed to push changes to it (and its branch?) I have a couple of fixes for the issues outlined by the |
Hi @ditman, I gave you write access to our fork of the plugins repo (https://github.com/baseflow/flutter-plugins) which should give you the required access to push changes to the branch (which will show up in the PR). You should have received an invite by email. Thanks for helping out! |
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.
Hey, I've checked this (except for the Java bits, maybe @bparrishMines can take a look at those), and I have a few comments. I don't think there's anything blocking. Some things are not very idiomatic. My only major concerns:
- Reexporting the whole camera_platform_interface from camera. Please reexport only the things that are being removed from Camera. That way we can expose things on platform_interface that are useful to other platform authors, but that shouldn't be directly seen by the users of the plugin.
- Do not import
dart:io
, that way the plugin will be marked as "WEB" compatible in pub.dev later!
} | ||
} | ||
} | ||
export 'package:camera_platform_interface/camera_platform_interface.dart'; |
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.
please, in this one, do show
explicitly the entities that we want to show from the platform_interface; that way it's harder to accidentally "leak" API if we add a public API on the platform_interface that might not be suited for end-user consumption (but is required for plugin authors, for example).
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 seem to have some problems with this one. Locally I have updated this statement to:
export 'package:camera_platform_interface/camera_platform_interface.dart'
show
CameraDescription,
CameraException,
CameraLensDirection,
ResolutionPreset,
XFile;
But now the code in the example/lib/main.dart won't compile anymore because it can't locate any of the types mentioned by the show
statement. I made sure I imported the import package:camera/camera.dart
Dart file but still not working.
I can't figure out what I am doing wrong here, probably overlooking something (it is getting late here). Maybe you have some pointers? Will give it a fresh look tomorrow morning.
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.
It should work, maybe you need a flutter clean in the example app, or to "restart" the analyzer (or both?).
If you want, push whatever you have to the branch and I can take a look on my end (it's going to break some tests, but oh well!)
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.
it was indeed my environment that got a bit confused, I corrected everything and it works without issues now. I guess I really needed to sleep on it ;)
} | ||
_isDisposed = true; | ||
super.dispose(); | ||
if (_creatingCompleter != null) { |
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 is the only usage of the _creatingCompleter, which seems to be only checking if the initalize method has been called (but not finished running). I've modified this by a FutureOr
, it's probable this can be simplified even further...
))); | ||
}); | ||
|
||
test('startImageStream() calls CameraPlatform', () 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.
Would it make sense to split the start/stop ImageStream tests to their own files, so we don't mix the PlatformInterface-based initialization and tests, with the MethodChannel ones?
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.
(Also for later cleanup, it's easier, just deleting a file)
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 agree, thanks for pointing it out. I moved the tests into a new file called camera_image_stream_test.dart
.
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent. |
I have added a couple of commits above, I don't think I've broken anything (tests seemed to continue passing), but please verify those! They have to do with the initialization sequence and how it used completers a little bit weirdly. (Also, when creating PRs, I think it's enough to mark the "allow maintainers to do changes to this PR" checkbox to enable me to push stuff to the branch, without having to give me access to the whole repo (but thanks anyway, Maurits!)) |
080812a
to
915cb1f
Compare
I just wondering why only the MINOR version has been increased? |
@AlexV525, @EvsioOn, @LaelLuo, @sunqihui222 it actually is a major version number. When a package is not considered stable (version 1.0.0) Dart considers the second digit the major number, the third digit as minor and a fourth digit (added as +n) as the patch number:
The quote above is copied from the article Package versioning | Dart, in particular the Semantic versions chapter. So in this case it is a major version update from 0.5.x+x to 0.6.0 |
https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0 This might be against to the migration proposal. The package using |
Not really sure how to answer this in a satisfying manor ;). The Flutter plugin teams follows the versioning semantics as discussed in the Package versioning | Dart article. As such we bumped the second digit to indicate a major version change. |
Thanks for the response. I think I'll consult others for the conflict later, since they're obviously against each other at present. |
…flutter#3302) * First suggestion for camera platform interface * Remove test coverage folder * Renamed onLatestImageAvailableHandler definition * Split CameraEvents into separate streams * Implemented & tested first parts of method channel implementation * Remove unused EventChannelMock class * Add missing unit tests * Added placeholders in default method channel implementation * Updated platform interface * Update packages/camera/camera_platform_interface/lib/src/platform_interface/camera_platform.dart Co-authored-by: Maurits van Beusekom <[email protected]> * Add unit test for availableCameras * Expand availableCameras unit test. Added unit test for takePicture. * Add unit test for startVideoRecording * Add unit test for prepareForVideoRecording * Add unit test for stopVideoRecording * Add unit test for pauseVideoRecording * Add unit test for buildView * WIP: Dart and Android implementation * Fix formatting * Have resolution stream replay last value on subscription. Replace stream_transform with rxdart. * Added reverse method channel to replace event channel. Updated initialise and takePicture implementations for android. WIP implementation for startVideoRecording * Fixed example app for Android. Removed isRecordingVideo and isStreamingImages from buildView method. * Added some first tests for camera/camera * More tests and some feedback * iOS implementation: Removed standard event channel. Added reverse method channel. Updated initialize method. Added resolution changed event. Updated error reporting to use new method channel. * Started splitting initialize method * Finish splitting up initialize for iOS * Update unit tests * Fix takePicture method on iOS * Split initialize method on Android * Fix video recording on iOS. Updated platform interface. * Update unit tests * Update error handling of video methods in iOS code. Make iOS code more consistent. * Updated startVideoRecording documentation * Make sure file is returned by stopVideoRecording * Use correct event-type after initializing * Fix DartMessenger unit-tests * Change cast * Fix formatting * Fixed tests, formatting and analysis warnings * Added missing license to Dart files * Updated CHANGELOG and version * Added additional unit-tests to platform_interface * Added more tests * Formatted code * Re-added the CameraPreview widget * Use import/export instead of part implementation * fixed formatting * Resolved additional feedback * Update dependency to git repo * Depend on pub.dev for camera_platform_interface * Fix JAVA formatting * Fix changelog * Make sure camera package can be published * Assert when stream methods are called from wrong platform * Add dev_dependency on plugin_platform_interface package, required by tests. * Remove pedantic requirement from initialize() method. Remove unnecessary completers. * Remove dependency on dart:io * Restrict exposed types from platform interface * Moved test for image stream in separate file * Fixed formatting issue * Fix deprecation warning * Apply feedback from bparrishMines * Fix formatting issues * Removed redundant podspec files * Removed redundant ios files * Handle SecurityException Co-authored-by: Maurits van Beusekom <[email protected]> Co-authored-by: Maurits van Beusekom <[email protected]> Co-authored-by: daniel <[email protected]> Co-authored-by: David Iglesias Teixeira <[email protected]>
…flutter#3302) * First suggestion for camera platform interface * Remove test coverage folder * Renamed onLatestImageAvailableHandler definition * Split CameraEvents into separate streams * Implemented & tested first parts of method channel implementation * Remove unused EventChannelMock class * Add missing unit tests * Added placeholders in default method channel implementation * Updated platform interface * Update packages/camera/camera_platform_interface/lib/src/platform_interface/camera_platform.dart Co-authored-by: Maurits van Beusekom <[email protected]> * Add unit test for availableCameras * Expand availableCameras unit test. Added unit test for takePicture. * Add unit test for startVideoRecording * Add unit test for prepareForVideoRecording * Add unit test for stopVideoRecording * Add unit test for pauseVideoRecording * Add unit test for buildView * WIP: Dart and Android implementation * Fix formatting * Have resolution stream replay last value on subscription. Replace stream_transform with rxdart. * Added reverse method channel to replace event channel. Updated initialise and takePicture implementations for android. WIP implementation for startVideoRecording * Fixed example app for Android. Removed isRecordingVideo and isStreamingImages from buildView method. * Added some first tests for camera/camera * More tests and some feedback * iOS implementation: Removed standard event channel. Added reverse method channel. Updated initialize method. Added resolution changed event. Updated error reporting to use new method channel. * Started splitting initialize method * Finish splitting up initialize for iOS * Update unit tests * Fix takePicture method on iOS * Split initialize method on Android * Fix video recording on iOS. Updated platform interface. * Update unit tests * Update error handling of video methods in iOS code. Make iOS code more consistent. * Updated startVideoRecording documentation * Make sure file is returned by stopVideoRecording * Use correct event-type after initializing * Fix DartMessenger unit-tests * Change cast * Fix formatting * Fixed tests, formatting and analysis warnings * Added missing license to Dart files * Updated CHANGELOG and version * Added additional unit-tests to platform_interface * Added more tests * Formatted code * Re-added the CameraPreview widget * Use import/export instead of part implementation * fixed formatting * Resolved additional feedback * Update dependency to git repo * Depend on pub.dev for camera_platform_interface * Fix JAVA formatting * Fix changelog * Make sure camera package can be published * Assert when stream methods are called from wrong platform * Add dev_dependency on plugin_platform_interface package, required by tests. * Remove pedantic requirement from initialize() method. Remove unnecessary completers. * Remove dependency on dart:io * Restrict exposed types from platform interface * Moved test for image stream in separate file * Fixed formatting issue * Fix deprecation warning * Apply feedback from bparrishMines * Fix formatting issues * Removed redundant podspec files * Removed redundant ios files * Handle SecurityException Co-authored-by: Maurits van Beusekom <[email protected]> Co-authored-by: Maurits van Beusekom <[email protected]> Co-authored-by: daniel <[email protected]> Co-authored-by: David Iglesias Teixeira <[email protected]>
Description
Updates the dart plugin and its native iOS and Android implementations to make use of the new platform interface that has been submitted in #3253
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?