This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split CameraEvents into separate streams
- Loading branch information
1 parent
96b40fc
commit 69f573b
Showing
7 changed files
with
107 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
packages/camera/camera_platform_interface/lib/src/events/camera_event.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import 'dart:ui'; | ||
|
||
/// Generic Event coming from the native side of Camera. | ||
/// | ||
/// All [CameraEvent]s contain the `cameraId` that originated the event. This | ||
/// should never be `null`. | ||
/// | ||
/// This class is used as a base class for all the events that might be | ||
/// triggered from a Camera, but it is never used directly as an event type. | ||
/// | ||
/// Do NOT instantiate new events like `CameraEvent(cameraId)` directly, | ||
/// use a specific class instead: | ||
/// | ||
/// Do `class NewEvent extend CameraEvent` when creating your own events. | ||
/// See below for examples: `CameraClosingEvent`, `CameraErrorEvent`... | ||
/// These events are more semantic and more pleasant to use than raw generics. | ||
/// They can be (and in fact, are) filtered by the `instanceof`-operator. | ||
abstract class CameraEvent { | ||
/// The ID of the Camera this event is associated to. | ||
final int cameraId; | ||
|
||
/// Build a Camera Event, that relates a `cameraId`. | ||
/// | ||
/// The `cameraId` is the ID of the camera that triggered the event. | ||
CameraEvent(this.cameraId); | ||
} | ||
|
||
/// An event fired when the resolution preset of the camera has changed. | ||
class ResolutionChangedEvent extends CameraEvent { | ||
/// The capture size in pixels. | ||
final Size captureSize; | ||
|
||
/// The size of the preview in pixels. | ||
final Size previewSize; | ||
|
||
/// Build a ResolutionChanged event triggered from the camera represented by | ||
/// `cameraId`. | ||
/// | ||
/// The `captureSize` represents the size of the resulting image in pixels. | ||
/// The `previewSize` represents the size of the generated preview in pixels. | ||
ResolutionChangedEvent(int cameraId, this.captureSize, this.previewSize) | ||
: super(cameraId); | ||
} | ||
|
||
/// An event fired when the camera is going to close. | ||
class CameraClosingEvent extends CameraEvent { | ||
/// Build a CameraClosing event triggered from the camera represented by | ||
/// `cameraId`. | ||
CameraClosingEvent(int cameraId) : super(cameraId); | ||
} | ||
|
||
/// An event fired when an error occured while operating the camera. | ||
class CameraErrorEvent extends CameraEvent { | ||
/// Description of the error. | ||
final String description; | ||
|
||
/// Build a CameraError event triggered from the camera represented by | ||
/// `cameraId`. | ||
/// | ||
/// The `description` represents the error occured on the camera. | ||
CameraErrorEvent(int cameraId, this.description) : super(cameraId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
packages/camera/camera_platform_interface/lib/src/types/callbacks.dart
This file was deleted.
Oops, something went wrong.
76 changes: 0 additions & 76 deletions
76
packages/camera/camera_platform_interface/lib/src/types/camera_event.dart
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.