Skip to content

Commit

Permalink
Release/1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
svprdga committed Jun 29, 2024
1 parent ba53bfe commit 2ada9e3
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 12 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [1.1.0] - 2024-06-29

### Added

- Update Gradle project to adapt it to the latest version
- Improved plugin documentation
- Updated example project

## [1.0.0] - 2022-10-31

### Changed
Expand Down
3 changes: 2 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ include: package:lint/analysis_options.yaml

linter:
rules:
avoid_classes_with_only_static_members: false
avoid_classes_with_only_static_members: false
public_member_api_docs: true
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.0"
version: "1.1.0"
vector_math:
dependency: transitive
description:
Expand Down
34 changes: 34 additions & 0 deletions lib/exceptions.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
part of 'torch_light.dart';

/// Exception thrown when an attempt was made to turn on the torch but it was
/// detected that the camera was being used by another process.
/// This means that the torch cannot be controlled.
class EnableTorchExistentUserException implements Exception {
/// Informative message about this exception.
String? message;

/// Exception thrown when an attempt was made to turn on the torch but it was
/// detected that the camera was being used by another process.
/// This means that the torch cannot be controlled.
EnableTorchExistentUserException({this.message});

@override
Expand All @@ -11,9 +18,14 @@ class EnableTorchExistentUserException implements Exception {
: "[EnableTorchExistentUserException]";
}

/// Exception thrown when an error occurred while trying to turn on the
/// device torch.
class EnableTorchException implements Exception {
/// Informative message about this exception.
String? message;

/// Exception thrown when an error occurred while trying to turn on the
/// device torch.
EnableTorchException({this.message});

@override
Expand All @@ -22,9 +34,14 @@ class EnableTorchException implements Exception {
: "[EnableTorchException]";
}

/// Exception thrown when an attempt was made to turn on the torch but it was
/// detected that the device does not have one equipped.
class EnableTorchNotAvailableException implements Exception {
/// Informative message about this exception.
String? message;

/// Exception thrown when an attempt was made to turn on the torch but it was
/// detected that the device does not have one equipped.
EnableTorchNotAvailableException({this.message});

@override
Expand All @@ -33,9 +50,16 @@ class EnableTorchNotAvailableException implements Exception {
: "[EnableTorchNotAvailableException]";
}

/// Exception thrown when an attempt was made to turn off the torch but it was
/// detected that the camera was being used by another process.
/// This means that the torch cannot be controlled.
class DisableTorchExistentUserException implements Exception {
/// Informative message about this exception.
String? message;

/// Exception thrown when an attempt was made to turn off the torch but it was
/// detected that the camera was being used by another process.
/// This means that the torch cannot be controlled.
DisableTorchExistentUserException({this.message});

@override
Expand All @@ -44,9 +68,14 @@ class DisableTorchExistentUserException implements Exception {
: "[DisableTorchExistentUserException]";
}

/// Exception thrown when an error occurred while trying to turn off the
/// device torch.
class DisableTorchException implements Exception {
/// Informative message about this exception.
String? message;

/// Exception thrown when an error occurred while trying to turn off the
/// device torch.
DisableTorchException({this.message});

@override
Expand All @@ -55,9 +84,14 @@ class DisableTorchException implements Exception {
: "[DisableTorchException]";
}

/// Exception thrown when an attempt was made to turn off the torch but it was
/// detected that the device does not have one equipped.
class DisableTorchNotAvailableException implements Exception {
/// Informative message about this exception.
String? message;

/// Exception thrown when an attempt was made to turn off the torch but it was
/// detected that the device does not have one equipped.
DisableTorchNotAvailableException({this.message});

@override
Expand Down
18 changes: 11 additions & 7 deletions lib/torch_light.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:flutter/services.dart';

part 'exceptions.dart';

/// This is the main class of the plugin from which it is possible to check
/// whether the device has a torch or not, and to turn it on and off.
class TorchLight {
// ****************************** CONSTANTS ****************************** //

Expand All @@ -29,7 +31,7 @@ class TorchLight {

/// Returns true if the device has a torch available, false otherwise.
///
/// Throws an [EnableTorchException] if the process encounters an error.
/// - Throws an [EnableTorchException] if the process encounters an error.
static Future<bool> isTorchAvailable() async {
try {
return await _channel.invokeMethod(_nativeEventIsTorchAvailable) as bool;
Expand All @@ -40,9 +42,10 @@ class TorchLight {

/// Enables the device torch.
///
/// Throws an [EnableTorchExistentUserException] if the camera is being used by another user.
/// Throws an [EnableTorchNotAvailableException] if a torch was not detected.
/// Throws an [EnableTorchException] if the process encounters an error.
/// - Throws an [EnableTorchExistentUserException] if the camera is being used
/// by another process.
/// - Throws an [EnableTorchNotAvailableException] if a torch was not detected.
/// - Throws an [EnableTorchException] if the process encounters an error.
static Future<void> enableTorch() async {
try {
await _channel.invokeMethod(_nativeEventEnableTorch);
Expand All @@ -60,9 +63,10 @@ class TorchLight {

/// Disables the device torch.
///
/// Throws a [DisableTorchExistentUserException] if the camera is being used by another user.
/// Throws a [DisableTorchNotAvailableException] if a torch was not detected.
/// Throws a [DisableTorchException] if the process encounters an error.
/// - Throws a [DisableTorchExistentUserException] if the camera is being used
/// by another process.
/// - Throws a [DisableTorchNotAvailableException] if a torch was not detected.
/// - Throws a [DisableTorchException] if the process encounters an error.
static Future<void> disableTorch() async {
try {
await _channel.invokeMethod(_nativeEventDisableTorch);
Expand Down
7 changes: 4 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: torch_light
description: A flutter plugin to control the device torch / flashlight.
version: 1.0.0
homepage: https://github.com/svprdga/torch_light
description: A Flutter plugin to check if the device has a torch / flashlight, and to turn it on and off.
version: 1.1.0
homepage: https://davidserrano.io/
repository: https://github.com/svprdga/torch_light

environment:
sdk: ">=2.17.5 <3.0.0"
Expand Down

0 comments on commit 2ada9e3

Please sign in to comment.