Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
[camera_platform_interface] Migrate to null safety (#3530)
Browse files Browse the repository at this point in the history
* Migrate camera_platform_interface to null safety

* Added camera to the NNBD plugin list

* Correct version number

* Convert optional parameters to required for CameraInitializationEvent

* Convert CameraId in test to non-nullable

* Test for null instead of enforcing non-null

* Attempt to fix dependency problem building all plugins

* Mark google_maps_flutter as NNBD

* Depend on correct Dart SDK version

* Attempt to fix dependency problem building all plugins

* Attempt to fix dependency problem building all plugins

* Attempt to fix dependency problem building all plugins

* Attempt to fix dependency problem building all plugins

* Add camera_platform_interface to exclude list

* Exclude camera from nnbd and non-nnbd

* Remove mockito dependency

* Make sure enableAudio is default false

* Include left-hand type definition

* Removed unused import statement
  • Loading branch information
mvanbeusekom authored Feb 9, 2021
1 parent ca25038 commit 2919660
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MethodChannelCamera extends CameraPlatform {
@override
Future<List<CameraDescription>> availableCameras() async {
try {
final cameras = await _channel
final List<Map<dynamic, dynamic>>? cameras = await _channel
.invokeListMethod<Map<dynamic, dynamic>>('availableCameras');

if (cameras == null) {
Expand All @@ -82,7 +82,7 @@ class MethodChannelCamera extends CameraPlatform {
Future<int> createCamera(
CameraDescription cameraDescription,
ResolutionPreset? resolutionPreset, {
bool enableAudio = true,
bool enableAudio = false,
}) async {
try {
final reply = await _channel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ abstract class CameraPlatform extends PlatformInterface {
}

/// Completes with a list of available cameras.
///
/// This method returns an empty list when no cameras are available.
Future<List<CameraDescription>> availableCameras() {
throw UnimplementedError('availableCameras() is not implemented.');
}
Expand All @@ -52,7 +54,7 @@ abstract class CameraPlatform extends PlatformInterface {
Future<int> createCamera(
CameraDescription cameraDescription,
ResolutionPreset? resolutionPreset, {
bool enableAudio = true,
bool enableAudio = false,
}) {
throw UnimplementedError('createCamera() is not implemented.');
}
Expand Down
1 change: 0 additions & 1 deletion packages/camera/camera_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dev_dependencies:
flutter_test:
sdk: flutter
async: ^2.5.0-nullsafety.3
mockito: ^5.0.0-nullsafety.5
pedantic: ^1.10.0-nullsafety.3

environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import 'package:camera_platform_interface/camera_platform_interface.dart';
import 'package:camera_platform_interface/src/method_channel/method_channel_camera.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand All @@ -27,11 +25,6 @@ void main() {
CameraPlatform.instance = ExtendsCameraPlatform();
});

test('Can be mocked with `implements`', () {
final mock = MockCameraPlatform();
CameraPlatform.instance = mock;
});

test(
'Default implementation of availableCameras() should throw unimplemented error',
() {
Expand Down Expand Up @@ -423,11 +416,4 @@ class ImplementsCameraPlatform implements CameraPlatform {
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}

class MockCameraPlatform extends Mock
with
// ignore: prefer_mixin
MockPlatformInterfaceMixin
implements
CameraPlatform {}

class ExtendsCameraPlatform extends CameraPlatform {}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void main() {
arguments: {
'cameraName': 'Test',
'resolutionPreset': 'high',
'enableAudio': true
'enableAudio': false
},
),
]);
Expand Down

0 comments on commit 2919660

Please sign in to comment.