This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,9 @@ class CameraController extends ValueNotifier<CameraValue> {
301301 /// Whether to include audio when recording a video.
302302 final bool enableAudio;
303303
304+ /// True after [CameraController.dispose] has completed successfully.
305+ bool get isDisposed => _isDisposed;
306+
304307 int _textureId;
305308 bool _isDisposed = false ;
306309 StreamSubscription <dynamic > _eventSubscription;
Original file line number Diff line number Diff line change 1+ // Copyright 2019 The Chromium Authors. All rights reserved.
2+ // Use of this source code is governed by a BSD-style license that can be
3+ // found in the LICENSE file.
4+
5+ import 'package:camera/camera.dart' ;
6+ import 'package:flutter_test/flutter_test.dart' ;
7+
8+ void main () {
9+ test ("isDisposed true when disposed" , () {
10+ final MockCameraDescription description = MockCameraDescription ();
11+ final CameraController controller = CameraController (
12+ description,
13+ ResolutionPreset .low,
14+ );
15+
16+ controller.dispose ();
17+ expect (controller.isDisposed, isTrue);
18+ });
19+
20+ test ("isDisposed false when not disposed" , () {
21+ final MockCameraDescription description = MockCameraDescription ();
22+ final CameraController controller = CameraController (
23+ description,
24+ ResolutionPreset .low,
25+ );
26+
27+ expect (controller.isDisposed, isFalse);
28+ });
29+ }
30+
31+ class MockCameraDescription extends CameraDescription {
32+ @override
33+ String get name => 'back' ;
34+ }
You can’t perform that action at this time.
0 commit comments