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

[camera_platform_interface] Migrate to null safety #3530

Merged
merged 21 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7c4e187
Migrate camera_platform_interface to null safety
mvanbeusekom Feb 2, 2021
bf94a5d
Added camera to the NNBD plugin list
mvanbeusekom Feb 2, 2021
c56c8c2
Correct version number
mvanbeusekom Feb 3, 2021
4fbbfd0
Convert optional parameters to required for CameraInitializationEvent
mvanbeusekom Feb 3, 2021
d3e86f1
Convert CameraId in test to non-nullable
mvanbeusekom Feb 3, 2021
025bc8d
Test for null instead of enforcing non-null
mvanbeusekom Feb 4, 2021
7f3db23
Attempt to fix dependency problem building all plugins
mvanbeusekom Feb 5, 2021
a8d251f
Mark google_maps_flutter as NNBD
mvanbeusekom Feb 5, 2021
cb539d5
Depend on correct Dart SDK version
mvanbeusekom Feb 6, 2021
d9d3271
Attempt to fix dependency problem building all plugins
mvanbeusekom Feb 6, 2021
e6e29b5
Attempt to fix dependency problem building all plugins
mvanbeusekom Feb 6, 2021
5e1f271
Attempt to fix dependency problem building all plugins
mvanbeusekom Feb 6, 2021
b4157dd
Attempt to fix dependency problem building all plugins
mvanbeusekom Feb 6, 2021
119c9cb
Add camera_platform_interface to exclude list
mvanbeusekom Feb 8, 2021
051b6a0
Exclude camera from nnbd and non-nnbd
mvanbeusekom Feb 8, 2021
17b872c
Remove mockito dependency
mvanbeusekom Feb 9, 2021
ffeb696
Make sure enableAudio is default false
mvanbeusekom Feb 9, 2021
31bdc4e
Include left-hand type definition
mvanbeusekom Feb 9, 2021
27de0de
Merged with master
mvanbeusekom Feb 9, 2021
ff6eaa0
Removed unused import statement
mvanbeusekom Feb 9, 2021
53d090d
Merge branch 'master' into nnbd_camera_platform_interface
mvanbeusekom Feb 9, 2021
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
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
Copy link
Member

Choose a reason for hiding this comment

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

This happened in several places across the code. I think as @bparrishMines suggested we should enable a lint to enforce either always adding (or never adding) this type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood, I will leave it like this for now and when we decide on which version we will go for I will make sure everything is corrected.

.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