-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera_web] Add onCameraClosing
implementation
#4259
[camera_web] Add onCameraClosing
implementation
#4259
Conversation
|
||
if (mounted) { | ||
setState(() {}); | ||
await previousCameraController?.dispose(); |
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 couldn't find a reason yet why CameraController.getMaxZoomLevel
and CameraController.getMinZoomLevel
throws a PlatformException
even though this type of exception is always mapped to CameraException
in these methods.
Added this to always dispose the previous camera controller even if an error occurred while initializing a new one.
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.
But maybe it should be added as a separate PR or as a part of #4240.
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.
Yes, this should be part of #4240 instead of this one.
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.
(added to 4240, and reverted 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.
Thanks!
…ase of an uncaught exception" This reverts commit ee5561a.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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 wonder if there's a possibility that we fire the onCameraClosing event twice (if the programmer calls "stop" and the user yanks the camera from the device, or similar). Probably not, because upon calling stop we clear the tracks, right?
Yeah, I believe so. Stopping the camera programatically stops all stream tracks (both video and audio) so they should no longer emit events about the stream being stopped for another reason. I have tested this, stopped the camera programmatically, then rejected the camera permissions. Normally, it emits an ended event but it didn't as the camera was stopped so it is fine I think. |
Adds
onCameraClosing
implementation to the web camera platform.onEnded
toCamera
(based onMediaStreamTrack.onEnded
).onCameraClosing
implementation.Camera.onEnded
).Part of flutter/flutter#45297.
Pre-launch Checklist
dart format
.)[shared_preferences]
///
).