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

Commit 5a8c22d

Browse files
committed
Convert CameraId in test to non-nullable
1 parent 24c5c6b commit 5a8c22d

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

packages/camera/camera_platform_interface/test/method_channel/method_channel_camera_test.dart

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ void main() {
376376

377377
group('Function Tests', () {
378378
late MethodChannelCamera camera;
379-
int? cameraId;
379+
late int cameraId;
380+
380381
setUp(() async {
381382
MethodChannelMock(
382383
channelName: 'plugins.flutter.io/camera',
@@ -394,10 +395,10 @@ void main() {
394395
),
395396
ResolutionPreset.high,
396397
);
397-
Future<void> initializeFuture = camera.initializeCamera(cameraId!);
398+
Future<void> initializeFuture = camera.initializeCamera(cameraId);
398399
camera.cameraEventStreamController.add(
399400
CameraInitializedEvent(
400-
cameraId!,
401+
cameraId,
401402
1920,
402403
1080,
403404
ExposureMode.auto,
@@ -470,7 +471,7 @@ void main() {
470471
methods: {'takePicture': '/test/path.jpg'});
471472

472473
// Act
473-
XFile file = await camera.takePicture(cameraId!);
474+
XFile file = await camera.takePicture(cameraId);
474475

475476
// Assert
476477
expect(channel.log, <Matcher>[
@@ -505,7 +506,7 @@ void main() {
505506
);
506507

507508
// Act
508-
await camera.startVideoRecording(cameraId!);
509+
await camera.startVideoRecording(cameraId);
509510

510511
// Assert
511512
expect(channel.log, <Matcher>[
@@ -526,7 +527,7 @@ void main() {
526527

527528
// Act
528529
await camera.startVideoRecording(
529-
cameraId!,
530+
cameraId,
530531
maxVideoDuration: Duration(seconds: 10),
531532
);
532533

@@ -545,7 +546,7 @@ void main() {
545546
);
546547

547548
// Act
548-
XFile file = await camera.stopVideoRecording(cameraId!);
549+
XFile file = await camera.stopVideoRecording(cameraId);
549550

550551
// Assert
551552
expect(channel.log, <Matcher>[
@@ -564,7 +565,7 @@ void main() {
564565
);
565566

566567
// Act
567-
await camera.pauseVideoRecording(cameraId!);
568+
await camera.pauseVideoRecording(cameraId);
568569

569570
// Assert
570571
expect(channel.log, <Matcher>[
@@ -582,7 +583,7 @@ void main() {
582583
);
583584

584585
// Act
585-
await camera.resumeVideoRecording(cameraId!);
586+
await camera.resumeVideoRecording(cameraId);
586587

587588
// Assert
588589
expect(channel.log, <Matcher>[
@@ -600,10 +601,10 @@ void main() {
600601
);
601602

602603
// Act
603-
await camera.setFlashMode(cameraId!, FlashMode.torch);
604-
await camera.setFlashMode(cameraId!, FlashMode.always);
605-
await camera.setFlashMode(cameraId!, FlashMode.auto);
606-
await camera.setFlashMode(cameraId!, FlashMode.off);
604+
await camera.setFlashMode(cameraId, FlashMode.torch);
605+
await camera.setFlashMode(cameraId, FlashMode.always);
606+
await camera.setFlashMode(cameraId, FlashMode.auto);
607+
await camera.setFlashMode(cameraId, FlashMode.off);
607608

608609
// Assert
609610
expect(channel.log, <Matcher>[
@@ -626,8 +627,8 @@ void main() {
626627
);
627628

628629
// Act
629-
await camera.setExposureMode(cameraId!, ExposureMode.auto);
630-
await camera.setExposureMode(cameraId!, ExposureMode.locked);
630+
await camera.setExposureMode(cameraId, ExposureMode.auto);
631+
await camera.setExposureMode(cameraId, ExposureMode.locked);
631632

632633
// Assert
633634
expect(channel.log, <Matcher>[
@@ -646,8 +647,8 @@ void main() {
646647
);
647648

648649
// Act
649-
await camera.setExposurePoint(cameraId!, Point<double>(0.5, 0.5));
650-
await camera.setExposurePoint(cameraId!, null);
650+
await camera.setExposurePoint(cameraId, Point<double>(0.5, 0.5));
651+
await camera.setExposurePoint(cameraId, null);
651652

652653
// Assert
653654
expect(channel.log, <Matcher>[
@@ -674,7 +675,7 @@ void main() {
674675
);
675676

676677
// Act
677-
final minExposureOffset = await camera.getMinExposureOffset(cameraId!);
678+
final minExposureOffset = await camera.getMinExposureOffset(cameraId);
678679

679680
// Assert
680681
expect(minExposureOffset, 2.0);
@@ -693,7 +694,7 @@ void main() {
693694
);
694695

695696
// Act
696-
final maxExposureOffset = await camera.getMaxExposureOffset(cameraId!);
697+
final maxExposureOffset = await camera.getMaxExposureOffset(cameraId);
697698

698699
// Assert
699700
expect(maxExposureOffset, 2.0);
@@ -712,7 +713,7 @@ void main() {
712713
);
713714

714715
// Act
715-
final stepSize = await camera.getExposureOffsetStepSize(cameraId!);
716+
final stepSize = await camera.getExposureOffsetStepSize(cameraId);
716717

717718
// Assert
718719
expect(stepSize, 0.25);
@@ -731,7 +732,7 @@ void main() {
731732
);
732733

733734
// Act
734-
final actualOffset = await camera.setExposureOffset(cameraId!, 0.5);
735+
final actualOffset = await camera.setExposureOffset(cameraId, 0.5);
735736

736737
// Assert
737738
expect(actualOffset, 0.6);
@@ -751,8 +752,8 @@ void main() {
751752
);
752753

753754
// Act
754-
await camera.setFocusMode(cameraId!, FocusMode.auto);
755-
await camera.setFocusMode(cameraId!, FocusMode.locked);
755+
await camera.setFocusMode(cameraId, FocusMode.auto);
756+
await camera.setFocusMode(cameraId, FocusMode.locked);
756757

757758
// Assert
758759
expect(channel.log, <Matcher>[
@@ -771,8 +772,8 @@ void main() {
771772
);
772773

773774
// Act
774-
await camera.setFocusPoint(cameraId!, Point<double>(0.5, 0.5));
775-
await camera.setFocusPoint(cameraId!, null);
775+
await camera.setFocusPoint(cameraId, Point<double>(0.5, 0.5));
776+
await camera.setFocusPoint(cameraId, null);
776777

777778
// Assert
778779
expect(channel.log, <Matcher>[
@@ -793,7 +794,7 @@ void main() {
793794

794795
test('Should build a texture widget as preview widget', () async {
795796
// Act
796-
Widget widget = camera.buildPreview(cameraId!);
797+
Widget widget = camera.buildPreview(cameraId);
797798

798799
// Act
799800
expect(widget is Texture, isTrue);
@@ -818,7 +819,7 @@ void main() {
818819
);
819820

820821
// Act
821-
final maxZoomLevel = await camera.getMaxZoomLevel(cameraId!);
822+
final maxZoomLevel = await camera.getMaxZoomLevel(cameraId);
822823

823824
// Assert
824825
expect(maxZoomLevel, 10.0);
@@ -837,7 +838,7 @@ void main() {
837838
);
838839

839840
// Act
840-
final maxZoomLevel = await camera.getMinZoomLevel(cameraId!);
841+
final maxZoomLevel = await camera.getMinZoomLevel(cameraId);
841842

842843
// Assert
843844
expect(maxZoomLevel, 1.0);
@@ -856,7 +857,7 @@ void main() {
856857
);
857858

858859
// Act
859-
await camera.setZoomLevel(cameraId!, 2.0);
860+
await camera.setZoomLevel(cameraId, 2.0);
860861

861862
// Assert
862863
expect(channel.log, <Matcher>[
@@ -881,7 +882,7 @@ void main() {
881882

882883
// Act & assert
883884
expect(
884-
() => camera.setZoomLevel(cameraId!, -1.0),
885+
() => camera.setZoomLevel(cameraId, -1.0),
885886
throwsA(isA<CameraException>()
886887
.having((e) => e.code, 'code', 'ZOOM_ERROR')
887888
.having((e) => e.description, 'description',
@@ -897,7 +898,7 @@ void main() {
897898

898899
// Act
899900
await camera.lockCaptureOrientation(
900-
cameraId!, DeviceOrientation.portraitUp);
901+
cameraId, DeviceOrientation.portraitUp);
901902

902903
// Assert
903904
expect(channel.log, <Matcher>[
@@ -914,7 +915,7 @@ void main() {
914915
);
915916

916917
// Act
917-
await camera.unlockCaptureOrientation(cameraId!);
918+
await camera.unlockCaptureOrientation(cameraId);
918919

919920
// Assert
920921
expect(channel.log, <Matcher>[

0 commit comments

Comments
 (0)