fluttertpc_torch_light:基于 Flutter 的设备手电筒管理插件项目

用户可借助此项目快速实现 Flutter 应用中设备手电筒的控制功能。该项目提供检测手电筒可用性、开关手电筒等核心功能,并支持详细的异常处理,便于开发者集成与调试。【此简介由AI生成】

Branch5Tags6
FilesLast commitLast update
2 years ago
2 years ago
4 years ago
2 years ago
5 years ago
5 years ago
5 years ago
2 years ago
5 years ago
3 years ago
2 years ago
2 years ago
2 years ago

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
}

Introduction

用户可借助此项目快速实现 Flutter 应用中设备手电筒的控制功能。该项目提供检测手电筒可用性、开关手电筒等核心功能,并支持详细的异常处理,便于开发者集成与调试。【此简介由AI生成】

Customize your domain