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

Commit 209cbde

Browse files
committed
Update feedback from Flutter team
2 parents eb056af + b609ea8 commit 209cbde

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

packages/camera/lib/camera.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

packages/camera/test/camera_test.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
}

0 commit comments

Comments
 (0)