FLUTTER ECOSYSTEM

svprdga/torch_light

기기 토치를 처리하는 간단한 플러터 플러그인입니다.

torch_light 프로젝트 이미지
Stars
7
Forks
6
최근 푸시(UTC)
2026. 8. 8.
프로젝트 상태
활성
David Serrano Canales GitHub avatar
GITHUB User

David Serrano Canales ↗

I am a software developer specialized in mobile apps. About a decade ago I started my career as a web developer, but I soon moved into Android native developmen

언어DartSwiftKotlinPythonRubyObjective-C

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 3 개
  • flutter{"sdk":"flutter"}
  • flutter_test개발 의존성{"sdk":"flutter"}
  • lint개발 의존성2.8.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

torch_light

style: lint

A simple Flutter plugin to manage the device torch / flashlight.

Import the library in your Dart code

import 'package:torch_light/torch_light.dart';

Check if the device has an available torch

try {
  final isTorchAvailable = await TorchLight.isTorchAvailable();
} on Exception catch (_) {
  // Handle error
}

Enable/disable torch

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
}