Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
[camera] Add missing Dartdocs (#3229)
Browse files Browse the repository at this point in the history
Added missing Dartdocs for the camera plugin in order to remove the custom analysis options file (which excludes the lint rule requiring documentation for all public APIs).
  • Loading branch information
amirh committed Oct 30, 2020
1 parent 3665c9f commit 8413efe
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 832 deletions.
4 changes: 4 additions & 0 deletions packages/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.8+13

* Added Dartdocs for all public APIs.

## 0.5.8+12

* Added information of video not working correctly on Android emulators to `README.md`.
Expand Down
10 changes: 0 additions & 10 deletions packages/camera/analysis_options.yaml

This file was deleted.

52 changes: 50 additions & 2 deletions packages/camera/lib/camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ part 'camera_image.dart';

final MethodChannel _channel = const MethodChannel('plugins.flutter.io/camera');

enum CameraLensDirection { front, back, external }
/// The direction the camera is facing.
enum CameraLensDirection {
/// Front facing camera (a user looking at the screen is seen by the camera).
front,

/// Back facing camera (a user looking at the screen is not seen by the camera).
back,

/// External camera which may not be mounted to the device.
external,
}

/// Affect the quality of video recording and image capture:
///
Expand All @@ -38,6 +48,9 @@ enum ResolutionPreset {
max,
}

/// Signature for a callback receiving the a camera image.
///
/// This is used by [CameraController.startImageStream].
// ignore: inference_failure_on_function_return_type
typedef onLatestImageAvailable = Function(CameraImage image);

Expand Down Expand Up @@ -91,10 +104,15 @@ Future<List<CameraDescription>> availableCameras() async {
}
}

/// Properties of a camera device.
class CameraDescription {
/// Creates a new camera description with the given properties.
CameraDescription({this.name, this.lensDirection, this.sensorOrientation});

/// The name of the camera device.
final String name;

/// The direction the camera is facing.
final CameraLensDirection lensDirection;

/// Clockwise angle through which the output image needs to be rotated to be upright on the device screen in its native orientation.
Expand Down Expand Up @@ -126,19 +144,27 @@ class CameraDescription {

/// This is thrown when the plugin reports an error.
class CameraException implements Exception {
/// Creates a new camera exception with the given error code and description.
CameraException(this.code, this.description);

/// Error code.
// TODO(bparrishMines): Document possible error codes.
// https://github.com/flutter/flutter/issues/69298
String code;

/// Textual description of the error.
String description;

@override
String toString() => '$runtimeType($code, $description)';
}

// Build the UI texture view of the video data with textureId.
/// A widget showing a live camera preview.
class CameraPreview extends StatelessWidget {
/// Creates a preview widget for the given camera controller.
const CameraPreview(this.controller);

/// The controller for the camera that the preview is shown for.
final CameraController controller;

@override
Expand All @@ -151,6 +177,7 @@ class CameraPreview extends StatelessWidget {

/// The state of a [CameraController].
class CameraValue {
/// Creates a new camera controller state.
const CameraValue({
this.isInitialized,
this.errorDescription,
Expand All @@ -161,6 +188,7 @@ class CameraValue {
bool isRecordingPaused,
}) : _isRecordingPaused = isRecordingPaused;

/// Creates a new camera controller state for an uninitialzed controller.
const CameraValue.uninitialized()
: this(
isInitialized: false,
Expand All @@ -187,6 +215,10 @@ class CameraValue {
/// True when camera [isRecordingVideo] and recording is paused.
bool get isRecordingPaused => isRecordingVideo && _isRecordingPaused;

/// Description of an error state.
///
/// This is null while the controller is not in an error state.
/// When [hasError] is true this contains the error description.
final String errorDescription;

/// The size of the preview in pixels.
Expand All @@ -199,8 +231,15 @@ class CameraValue {
/// Can only be called when [initialize] is done.
double get aspectRatio => previewSize.height / previewSize.width;

/// Whether the controller is in an error state.
///
/// When true [errorDescription] describes the error.
bool get hasError => errorDescription != null;

/// Creates a modified copy of the object.
///
/// Explicitly specified fields get the specified value, all other fields get
/// the same value of the current object.
CameraValue copyWith({
bool isInitialized,
bool isRecordingVideo,
Expand Down Expand Up @@ -241,13 +280,22 @@ class CameraValue {
///
/// To show the camera preview on the screen use a [CameraPreview] widget.
class CameraController extends ValueNotifier<CameraValue> {
/// Creates a new camera controller in an uninitialized state.
CameraController(
this.description,
this.resolutionPreset, {
this.enableAudio = true,
}) : super(const CameraValue.uninitialized());

/// The properties of the camera device controlled by this controller.
final CameraDescription description;

/// The resolution this controller is targeting.
///
/// This resolution preset is not guaranteed to be available on the device,
/// if unavailable a lower resolution will be used.
///
/// See also: [ResolutionPreset].
final ResolutionPreset resolutionPreset;

/// Whether to include audio when recording a video.
Expand Down
10 changes: 0 additions & 10 deletions packages/camera/lib/new/camera.dart

This file was deleted.

171 changes: 0 additions & 171 deletions packages/camera/lib/new/src/camera_controller.dart

This file was deleted.

17 changes: 0 additions & 17 deletions packages/camera/lib/new/src/camera_testing.dart

This file was deleted.

38 changes: 0 additions & 38 deletions packages/camera/lib/new/src/common/camera_channel.dart

This file was deleted.

0 comments on commit 8413efe

Please sign in to comment.