flashlight_plugin 0.0.1
flashlight_plugin: ^0.0.1 copied to clipboard
A Flutter Plugin to control the flashlight on android devices that are Android 6.0 or higher
flashlight_plugin #
A Flutter plugin to control the device flashlight on Android.
Features #
- Turn flashlight on/off
- Check flashlight availability
- Toggle flashlight state
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
flashlight_plugin: ^0.0.1
Usage #
import 'package:flashlight_plugin/flashlight_plugin.dart';
// Check if flashlight is available
bool hasFlash = await FlashlightPlugin.hasFlashlight();
// Turn on the flashlight
await FlashlightPlugin.turnOn();
// Turn off the flashlight
await FlashlightPlugin.turnOff();
// Toggle flashlight
await FlashlightPlugin.toggle();
Android Setup #
Add the following permissions to your android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.flash" />
Requirements #
- Android API 23 (Android 6.0) or higher
- Flutter 3.0.0 or higher
LICENSE #
MIT License