This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree 2 files changed +21
-6
lines changed 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -307,8 +307,12 @@ class CameraController extends ValueNotifier<CameraValue> {
307
307
StreamSubscription <dynamic > _imageStreamSubscription;
308
308
Completer <void > _creatingCompleter;
309
309
310
- /// True after [CameraController.dispose] has completed successfully.
311
- bool get isDisposed => _isDisposed;
310
+ /// Checks whether [CameraController.dispose] has completed successfully.
311
+ ///
312
+ /// This is a no-op when asserts are disabled.
313
+ void debugCheckIsDisposed () {
314
+ assert (_isDisposed);
315
+ }
312
316
313
317
/// Initializes the camera on the device.
314
318
///
Original file line number Diff line number Diff line change @@ -6,25 +6,36 @@ import 'package:flutter_test/flutter_test.dart';
6
6
7
7
void main () {
8
8
group ('camera' , () {
9
- test ("isDisposed true when disposed" , () {
9
+ test ('debugCheckIsDisposed should not throw assertion error when disposed' , () {
10
10
final MockCameraDescription description = MockCameraDescription ();
11
11
final CameraController controller = CameraController (
12
12
description,
13
13
ResolutionPreset .low,
14
14
);
15
15
16
16
controller.dispose ();
17
- expect (controller.isDisposed, isTrue);
17
+
18
+ try {
19
+ controller.debugCheckIsDisposed ();
20
+ } on AssertionError {
21
+ fail (
22
+ 'debugCheckIsDisposed should not throw if the camera controller is not disposed.' );
23
+ }
18
24
});
19
25
20
- test ("isDisposed false when not disposed" , () {
26
+ test (
27
+ 'debugCheckIsDisposed should throw assertion error when not disposed' ,
28
+ () {
21
29
final MockCameraDescription description = MockCameraDescription ();
22
30
final CameraController controller = CameraController (
23
31
description,
24
32
ResolutionPreset .low,
25
33
);
26
34
27
- expect (controller.isDisposed, isFalse);
35
+ expect (
36
+ () => controller.debugCheckIsDisposed (),
37
+ throwsAssertionError,
38
+ );
28
39
});
29
40
});
30
41
}
You can’t perform that action at this time.
0 commit comments