Skip to content
pubscout

torch_light

2.0.0, released 6 months ago by davidserrano.io

Check if device has a torch and turn it on or off.

WASM-ready
$ flutter pub add torch_light
Source repository

What it does

A Flutter plugin that checks if the device has an available torch/flashlight, and provides methods to enable and disable it. It includes specific exception handling for scenarios like camera in use or torch not available.

AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to turn the device flashlight on or off programmatically.
  • You need to check if a torch is available on the current device.

Skip it when

  • You are building a full camera application that handles video capturing and custom camera controls.

Strengths

  • Simple and straightforward API for torch management
  • Comprehensive error handling with specific exceptions

Weaknesses

  • Limited to a single specific device feature (torch control)

Setup

Kind
Plugin (native code)
Effort
Low
Code generation
No
Direct dependencies
0

Requires Android SDK 6.0 (API level 23) or higher. Built-in Kotlin and Swift Package Manager support.

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

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

Alternatives

Packages that do the same job and could replace torch_light.