Skip to content

Commit 994e342

Browse files
authored
Merge pull request #9 from Baseflow/subpr/camera_federated/platform-interface-xfile
Updated platform interface to have recording methods return XFile instances
2 parents 69f573b + 6c32fa9 commit 994e342

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

packages/camera/camera_platform_interface/lib/src/platform_interface/camera_platform.dart

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
import 'dart:async';
66

7+
import 'package:camera_platform_interface/src/method_channel/method_channel_camera.dart';
8+
import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
79
import 'package:flutter/widgets.dart';
810
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
9-
import 'package:camera_platform_interface/src/method_channel/method_channel_camera.dart';
1011

1112
import '../../camera_platform_interface.dart';
1213

@@ -66,8 +67,8 @@ abstract class CameraPlatform extends PlatformInterface {
6667
throw UnimplementedError('onCameraError() is not implemented.');
6768
}
6869

69-
/// Captures an image and saves it to [path].
70-
Future<void> takePicture(int cameraId, String path) {
70+
/// Captures an image and returns the file where it was saved.
71+
Future<XFile> takePicture(int cameraId) {
7172
throw UnimplementedError('takePicture() is not implemented.');
7273
}
7374

@@ -76,19 +77,19 @@ abstract class CameraPlatform extends PlatformInterface {
7677
throw UnimplementedError('prepareForVideoRecording() is not implemented.');
7778
}
7879

79-
/// Start a video recording and save the file to [path].
80-
///
81-
/// A path can for example be obtained using
82-
/// [path_provider](https://pub.dartlang.org/packages/path_provider).
80+
/// Starts a video recording and returns the file where it will be saved.
8381
///
8482
/// The file is written on the flight as the video is being recorded.
85-
/// If a file already exists at the provided path an error will be thrown.
8683
/// The file can be read as soon as [stopVideoRecording] returns.
87-
Future<void> startVideoRecording(int cameraId, String path) {
84+
Future<XFile> startVideoRecording(int cameraId) {
8885
throw UnimplementedError('startVideoRecording() is not implemented.');
8986
}
9087

91-
/// Stop the video recording.
88+
/// Stops the video recording.
89+
///
90+
/// When the [stopVideoRecording] method completes successfully the recorded
91+
/// video can be accessed through the file returned by the
92+
/// [startVideoRecording] method.
9293
Future<void> stopVideoRecording(int cameraId) {
9394
throw UnimplementedError('stopVideoRecording() is not implemented.');
9495
}

packages/camera/camera_platform_interface/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
sdk: flutter
1111
meta: ^1.0.5
1212
plugin_platform_interface: ^1.0.1
13+
file_selector_platform_interface: ^1.0.0
1314

1415
dev_dependencies:
1516
flutter_test:

packages/camera/camera_platform_interface/test/camera_platform_interface_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void main() {
156156

157157
// Act & Assert
158158
expect(
159-
() => cameraPlatform.startVideoRecording(1, null),
159+
() => cameraPlatform.startVideoRecording(1),
160160
throwsUnimplementedError,
161161
);
162162
});
@@ -182,7 +182,7 @@ void main() {
182182

183183
// Act & Assert
184184
expect(
185-
() => cameraPlatform.takePicture(1, null),
185+
() => cameraPlatform.takePicture(1),
186186
throwsUnimplementedError,
187187
);
188188
});

0 commit comments

Comments
 (0)