Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add some more newlines and add a check to ensure streamOptions fails …
…if no streamCallback
  • Loading branch information
Adam Harwood committed Oct 21, 2022
commit 0fd25e756860ce05eb7e6156fa8deb6efb5c3646
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ import 'camera_image_data.dart';
@immutable
class VideoCaptureOptions {
/// Constructs a new instance.
const VideoCaptureOptions(
VideoCaptureOptions(
this.cameraId, {
this.maxDuration,
this.streamCallback,
this.streamOptions,
});
}) {
if (streamOptions != null && streamCallback == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think the preferred way would be to just use an assert. e.g:

VideoCaptureOptions(
    this.cameraId, {
    this.maxDuration,
    this.streamCallback,
    this.streamOptions,
  }) : assert(
          streamOptions == null || streamCallback != null,
          'Must specify streamCallback if providing streamOptions.',
        );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've made this change.

throw ArgumentError('Must specify streamCallback if providing streamOptions');
}
}

/// The ID of the camera to use for capturing.
final int cameraId;
Expand All @@ -26,11 +30,13 @@ class VideoCaptureOptions {
final Duration? maxDuration;

/// An optional callback to enable streaming.
///
/// If set, then each image captured by the camera will be
/// passed to this callback.
final Function(CameraImageData image)? streamCallback;

/// Configuration options for streaming.
///
/// Should only be set if a streamCallback is also present.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is true, can you add an assertion to the constructor that verifies this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done.

final CameraImageStreamOptions? streamOptions;

Expand Down