Skip to content

Commit 8413efe

Browse files
authored
[camera] Add missing Dartdocs (flutter#3229)
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).
1 parent 3665c9f commit 8413efe

16 files changed

+55
-832
lines changed

packages/camera/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.8+13
2+
3+
* Added Dartdocs for all public APIs.
4+
15
## 0.5.8+12
26

37
* Added information of video not working correctly on Android emulators to `README.md`.

packages/camera/analysis_options.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/camera/lib/camera.dart

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@ part 'camera_image.dart';
1313

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

16-
enum CameraLensDirection { front, back, external }
16+
/// The direction the camera is facing.
17+
enum CameraLensDirection {
18+
/// Front facing camera (a user looking at the screen is seen by the camera).
19+
front,
20+
21+
/// Back facing camera (a user looking at the screen is not seen by the camera).
22+
back,
23+
24+
/// External camera which may not be mounted to the device.
25+
external,
26+
}
1727

1828
/// Affect the quality of video recording and image capture:
1929
///
@@ -38,6 +48,9 @@ enum ResolutionPreset {
3848
max,
3949
}
4050

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

@@ -91,10 +104,15 @@ Future<List<CameraDescription>> availableCameras() async {
91104
}
92105
}
93106

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

112+
/// The name of the camera device.
97113
final String name;
114+
115+
/// The direction the camera is facing.
98116
final CameraLensDirection lensDirection;
99117

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

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

150+
/// Error code.
151+
// TODO(bparrishMines): Document possible error codes.
152+
// https://github.com/flutter/flutter/issues/69298
131153
String code;
154+
155+
/// Textual description of the error.
132156
String description;
133157

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

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

167+
/// The controller for the camera that the preview is shown for.
142168
final CameraController controller;
143169

144170
@override
@@ -151,6 +177,7 @@ class CameraPreview extends StatelessWidget {
151177

152178
/// The state of a [CameraController].
153179
class CameraValue {
180+
/// Creates a new camera controller state.
154181
const CameraValue({
155182
this.isInitialized,
156183
this.errorDescription,
@@ -161,6 +188,7 @@ class CameraValue {
161188
bool isRecordingPaused,
162189
}) : _isRecordingPaused = isRecordingPaused;
163190

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

218+
/// Description of an error state.
219+
///
220+
/// This is null while the controller is not in an error state.
221+
/// When [hasError] is true this contains the error description.
190222
final String errorDescription;
191223

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

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

239+
/// Creates a modified copy of the object.
240+
///
241+
/// Explicitly specified fields get the specified value, all other fields get
242+
/// the same value of the current object.
204243
CameraValue copyWith({
205244
bool isInitialized,
206245
bool isRecordingVideo,
@@ -241,13 +280,22 @@ class CameraValue {
241280
///
242281
/// To show the camera preview on the screen use a [CameraPreview] widget.
243282
class CameraController extends ValueNotifier<CameraValue> {
283+
/// Creates a new camera controller in an uninitialized state.
244284
CameraController(
245285
this.description,
246286
this.resolutionPreset, {
247287
this.enableAudio = true,
248288
}) : super(const CameraValue.uninitialized());
249289

290+
/// The properties of the camera device controlled by this controller.
250291
final CameraDescription description;
292+
293+
/// The resolution this controller is targeting.
294+
///
295+
/// This resolution preset is not guaranteed to be available on the device,
296+
/// if unavailable a lower resolution will be used.
297+
///
298+
/// See also: [ResolutionPreset].
251299
final ResolutionPreset resolutionPreset;
252300

253301
/// Whether to include audio when recording a video.

packages/camera/lib/new/camera.dart

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/camera/lib/new/src/camera_controller.dart

Lines changed: 0 additions & 171 deletions
This file was deleted.

packages/camera/lib/new/src/camera_testing.dart

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/camera/lib/new/src/common/camera_channel.dart

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)