v1.1.0
torch_light
기기가 토치/플래시가 있는지 확인하고 켜고 끌 수 있는 Flutter 플러그인입니다.
61좋아요 2.2만30일 다운로드150Pub 점수
AndroidiOS
기기 토치를 처리하는 간단한 플러터 플러그인입니다.
{"sdk":"flutter"}{"sdk":"flutter"}2.8.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
A simple Flutter plugin to manage the device torch / flashlight.
import 'package:torch_light/torch_light.dart';
try {
final isTorchAvailable = await TorchLight.isTorchAvailable();
} on Exception catch (_) {
// Handle error
}
Enable and disable the device torch / flash:
try {
await TorchLight.enableTorch();
} on Exception catch (_) {
// Handle error
}
try {
await TorchLight.disableTorch();
} on Exception catch (_) {
// Handle error
}
If you want further control over the errors, you can declare explicit exceptions:
// Enable torch and manage all kind of errors
try {
await TorchLight.enableTorch();
} on EnableTorchExistentUserException catch (e) {
// The camera is in use
} on EnableTorchNotAvailableException catch (e) {
// Torch was not detected
} on EnableTorchException catch (e) {
// Torch could not be enabled due to another error
}
// Disable torch and manage all kind of errors
try {
await TorchLight.disableTorch();
} on DisableTorchExistentUserException catch (e) {
// The camera is in use
} on DisableTorchNotAvailableException catch (e) {
// Torch was not detected
} on DisableTorchException catch (e) {
// Torch could not be disabled due to another error
}