-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera] Expanded platform interface to support setting flash mode #3313
[camera] Expanded platform interface to support setting flash mode #3313
Conversation
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.
LGTM, can be merged when tree goes green
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 great! And it seems to be implementable in web!
My only recommendation is not to rely on the toString method of the FlashMode Enum, and instead have a translation table from enum -> string. Other than that, ship it!
'setFlashMode', | ||
<String, dynamic>{ | ||
'cameraId': cameraId, | ||
'mode': mode.toString().split('.').last, |
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'd recommend doing a Map<FlashMode, String>
to do this conversion, instead of relying on the "toString" representation of the Enum.
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.
LGTM
String _serializeFlashMode(FlashMode flashMode) { | ||
switch (flashMode) { | ||
case FlashMode.off: | ||
return 'off'; | ||
case FlashMode.auto: | ||
return 'auto'; | ||
case FlashMode.always: | ||
return 'always'; | ||
} | ||
} |
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 should handle the default
case and throw an argument error explaining the supplied value cannot be supported.
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.
Left a comment after flutter analyze
failed.
…lutter#3313) * Expanded platform interface so support setting flash mode * Formatted dart code * Manually serialize flash mode enum rather than relying on stringification. * Add default to flash mode serialization
…lutter#3313) * Expanded platform interface so support setting flash mode * Formatted dart code * Manually serialize flash mode enum rather than relying on stringification. * Add default to flash mode serialization
…m-changes * upstream-share-final-null-release: (233 commits) [q-w] Update Flutter SDK constraint (flutter#3323) [i-p] Update Flutter SDK constraint (flutter#3322) [d-g] Update Flutter SDK constraint (flutter#3321) [a-c] Update Flutter SDK constraint (flutter#3320) [image_picker_platform_interface] Pass Uri to package:http APIs (flutter#3309) Exclude null-safe plugins from testing on stable (flutter#3318) [documentation] [url_launcher] fix for readme code sample (flutter#3308) [camera] Add zoom support to platform interface (flutter#3312) update analysis options for nnbd (flutter#3319) [camera] Suppress unchecked cast warning in java test (flutter#3316) [image_picker] [integration_test] Fixes to make the tree green (flutter#3317) [camera] Expanded platform interface to support setting flash mode (flutter#3313) [Espresso] Android Code Inspection and Clean up (flutter#3111) [camera] Add `camera_platform_interface` package (flutter#3253) [camera] Support Android 30 (flutter#3299) bump integration test to 1.0.0 (flutter#3295) [android_alarm_manager] fix AndroidManifest.xml for android lint issue "XML tag has empty body" (flutter#3288) Use testWidgets instead of test to fix failures not surfacing on CI (flutter#3279) [file_selector_platform_interface] Migrate to cross_file package (flutter#3286) Fix broken link (flutter#3280) ...
Description
Adds the required methods necessary to implement flash support to the camera_platform_interface. Once this PR has landed packages implementing the camera_platform_interface will be able to add flash support to the camera implementations.
Related Issues
flutter/flutter#19845
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?