@@ -376,7 +376,8 @@ void main() {
376
376
377
377
group ('Function Tests' , () {
378
378
late MethodChannelCamera camera;
379
- int ? cameraId;
379
+ late int cameraId;
380
+
380
381
setUp (() async {
381
382
MethodChannelMock (
382
383
channelName: 'plugins.flutter.io/camera' ,
@@ -394,10 +395,10 @@ void main() {
394
395
),
395
396
ResolutionPreset .high,
396
397
);
397
- Future <void > initializeFuture = camera.initializeCamera (cameraId! );
398
+ Future <void > initializeFuture = camera.initializeCamera (cameraId);
398
399
camera.cameraEventStreamController.add (
399
400
CameraInitializedEvent (
400
- cameraId! ,
401
+ cameraId,
401
402
1920 ,
402
403
1080 ,
403
404
ExposureMode .auto,
@@ -470,7 +471,7 @@ void main() {
470
471
methods: {'takePicture' : '/test/path.jpg' });
471
472
472
473
// Act
473
- XFile file = await camera.takePicture (cameraId! );
474
+ XFile file = await camera.takePicture (cameraId);
474
475
475
476
// Assert
476
477
expect (channel.log, < Matcher > [
@@ -505,7 +506,7 @@ void main() {
505
506
);
506
507
507
508
// Act
508
- await camera.startVideoRecording (cameraId! );
509
+ await camera.startVideoRecording (cameraId);
509
510
510
511
// Assert
511
512
expect (channel.log, < Matcher > [
@@ -526,7 +527,7 @@ void main() {
526
527
527
528
// Act
528
529
await camera.startVideoRecording (
529
- cameraId! ,
530
+ cameraId,
530
531
maxVideoDuration: Duration (seconds: 10 ),
531
532
);
532
533
@@ -545,7 +546,7 @@ void main() {
545
546
);
546
547
547
548
// Act
548
- XFile file = await camera.stopVideoRecording (cameraId! );
549
+ XFile file = await camera.stopVideoRecording (cameraId);
549
550
550
551
// Assert
551
552
expect (channel.log, < Matcher > [
@@ -564,7 +565,7 @@ void main() {
564
565
);
565
566
566
567
// Act
567
- await camera.pauseVideoRecording (cameraId! );
568
+ await camera.pauseVideoRecording (cameraId);
568
569
569
570
// Assert
570
571
expect (channel.log, < Matcher > [
@@ -582,7 +583,7 @@ void main() {
582
583
);
583
584
584
585
// Act
585
- await camera.resumeVideoRecording (cameraId! );
586
+ await camera.resumeVideoRecording (cameraId);
586
587
587
588
// Assert
588
589
expect (channel.log, < Matcher > [
@@ -600,10 +601,10 @@ void main() {
600
601
);
601
602
602
603
// 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);
607
608
608
609
// Assert
609
610
expect (channel.log, < Matcher > [
@@ -626,8 +627,8 @@ void main() {
626
627
);
627
628
628
629
// 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);
631
632
632
633
// Assert
633
634
expect (channel.log, < Matcher > [
@@ -646,8 +647,8 @@ void main() {
646
647
);
647
648
648
649
// 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 );
651
652
652
653
// Assert
653
654
expect (channel.log, < Matcher > [
@@ -674,7 +675,7 @@ void main() {
674
675
);
675
676
676
677
// Act
677
- final minExposureOffset = await camera.getMinExposureOffset (cameraId! );
678
+ final minExposureOffset = await camera.getMinExposureOffset (cameraId);
678
679
679
680
// Assert
680
681
expect (minExposureOffset, 2.0 );
@@ -693,7 +694,7 @@ void main() {
693
694
);
694
695
695
696
// Act
696
- final maxExposureOffset = await camera.getMaxExposureOffset (cameraId! );
697
+ final maxExposureOffset = await camera.getMaxExposureOffset (cameraId);
697
698
698
699
// Assert
699
700
expect (maxExposureOffset, 2.0 );
@@ -712,7 +713,7 @@ void main() {
712
713
);
713
714
714
715
// Act
715
- final stepSize = await camera.getExposureOffsetStepSize (cameraId! );
716
+ final stepSize = await camera.getExposureOffsetStepSize (cameraId);
716
717
717
718
// Assert
718
719
expect (stepSize, 0.25 );
@@ -731,7 +732,7 @@ void main() {
731
732
);
732
733
733
734
// Act
734
- final actualOffset = await camera.setExposureOffset (cameraId! , 0.5 );
735
+ final actualOffset = await camera.setExposureOffset (cameraId, 0.5 );
735
736
736
737
// Assert
737
738
expect (actualOffset, 0.6 );
@@ -751,8 +752,8 @@ void main() {
751
752
);
752
753
753
754
// 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);
756
757
757
758
// Assert
758
759
expect (channel.log, < Matcher > [
@@ -771,8 +772,8 @@ void main() {
771
772
);
772
773
773
774
// 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 );
776
777
777
778
// Assert
778
779
expect (channel.log, < Matcher > [
@@ -793,7 +794,7 @@ void main() {
793
794
794
795
test ('Should build a texture widget as preview widget' , () async {
795
796
// Act
796
- Widget widget = camera.buildPreview (cameraId! );
797
+ Widget widget = camera.buildPreview (cameraId);
797
798
798
799
// Act
799
800
expect (widget is Texture , isTrue);
@@ -818,7 +819,7 @@ void main() {
818
819
);
819
820
820
821
// Act
821
- final maxZoomLevel = await camera.getMaxZoomLevel (cameraId! );
822
+ final maxZoomLevel = await camera.getMaxZoomLevel (cameraId);
822
823
823
824
// Assert
824
825
expect (maxZoomLevel, 10.0 );
@@ -837,7 +838,7 @@ void main() {
837
838
);
838
839
839
840
// Act
840
- final maxZoomLevel = await camera.getMinZoomLevel (cameraId! );
841
+ final maxZoomLevel = await camera.getMinZoomLevel (cameraId);
841
842
842
843
// Assert
843
844
expect (maxZoomLevel, 1.0 );
@@ -856,7 +857,7 @@ void main() {
856
857
);
857
858
858
859
// Act
859
- await camera.setZoomLevel (cameraId! , 2.0 );
860
+ await camera.setZoomLevel (cameraId, 2.0 );
860
861
861
862
// Assert
862
863
expect (channel.log, < Matcher > [
@@ -881,7 +882,7 @@ void main() {
881
882
882
883
// Act & assert
883
884
expect (
884
- () => camera.setZoomLevel (cameraId! , - 1.0 ),
885
+ () => camera.setZoomLevel (cameraId, - 1.0 ),
885
886
throwsA (isA <CameraException >()
886
887
.having ((e) => e.code, 'code' , 'ZOOM_ERROR' )
887
888
.having ((e) => e.description, 'description' ,
@@ -897,7 +898,7 @@ void main() {
897
898
898
899
// Act
899
900
await camera.lockCaptureOrientation (
900
- cameraId! , DeviceOrientation .portraitUp);
901
+ cameraId, DeviceOrientation .portraitUp);
901
902
902
903
// Assert
903
904
expect (channel.log, < Matcher > [
@@ -914,7 +915,7 @@ void main() {
914
915
);
915
916
916
917
// Act
917
- await camera.unlockCaptureOrientation (cameraId! );
918
+ await camera.unlockCaptureOrientation (cameraId);
918
919
919
920
// Assert
920
921
expect (channel.log, < Matcher > [
0 commit comments