FLUTTER ECOSYSTEM

svprdga/torch_light

デバイスのライトを扱うためのシンプルなFlutterプラグイン。

torch_light のプロジェクト画像
Stars
7
Forks
6
最終プッシュ(UTC)
2026/08/08
プロジェクト状態
公開中
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

Self-employed公式サイト ↗
言語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
}