flet-flashlight 0.1.0.dev1__tar.gz → 0.70.0.dev6611__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flet-flashlight might be problematic. Click here for more details.

Files changed (31) hide show
  1. {flet_flashlight-0.1.0.dev1/src/flutter/flet_flashlight → flet_flashlight-0.70.0.dev6611}/LICENSE +1 -1
  2. flet_flashlight-0.70.0.dev6611/PKG-INFO +58 -0
  3. flet_flashlight-0.70.0.dev6611/README.md +42 -0
  4. flet_flashlight-0.70.0.dev6611/pyproject.toml +24 -0
  5. flet_flashlight-0.70.0.dev6611/src/flet_flashlight/__init__.py +21 -0
  6. flet_flashlight-0.70.0.dev6611/src/flet_flashlight/exceptions.py +65 -0
  7. flet_flashlight-0.70.0.dev6611/src/flet_flashlight/flashlight.py +89 -0
  8. flet_flashlight-0.70.0.dev6611/src/flet_flashlight.egg-info/PKG-INFO +58 -0
  9. {flet_flashlight-0.1.0.dev1 → flet_flashlight-0.70.0.dev6611}/src/flet_flashlight.egg-info/SOURCES.txt +3 -4
  10. flet_flashlight-0.70.0.dev6611/src/flet_flashlight.egg-info/requires.txt +1 -0
  11. {flet_flashlight-0.1.0.dev1 → flet_flashlight-0.70.0.dev6611}/src/flutter/flet_flashlight/analysis_options.yaml +1 -1
  12. flet_flashlight-0.70.0.dev6611/src/flutter/flet_flashlight/lib/flet_flashlight.dart +3 -0
  13. flet_flashlight-0.70.0.dev6611/src/flutter/flet_flashlight/lib/src/extension.dart +15 -0
  14. flet_flashlight-0.70.0.dev6611/src/flutter/flet_flashlight/lib/src/flashlight.dart +101 -0
  15. {flet_flashlight-0.1.0.dev1 → flet_flashlight-0.70.0.dev6611}/src/flutter/flet_flashlight/pubspec.lock +203 -140
  16. {flet_flashlight-0.1.0.dev1 → flet_flashlight-0.70.0.dev6611}/src/flutter/flet_flashlight/pubspec.yaml +11 -6
  17. flet_flashlight-0.1.0.dev1/PKG-INFO +0 -39
  18. flet_flashlight-0.1.0.dev1/README.md +0 -25
  19. flet_flashlight-0.1.0.dev1/pyproject.toml +0 -36
  20. flet_flashlight-0.1.0.dev1/src/flet_flashlight/__init__.py +0 -1
  21. flet_flashlight-0.1.0.dev1/src/flet_flashlight/flashlight.py +0 -85
  22. flet_flashlight-0.1.0.dev1/src/flet_flashlight.egg-info/PKG-INFO +0 -39
  23. flet_flashlight-0.1.0.dev1/src/flet_flashlight.egg-info/requires.txt +0 -1
  24. flet_flashlight-0.1.0.dev1/src/flutter/flet_flashlight/CHANGELOG.md +0 -3
  25. flet_flashlight-0.1.0.dev1/src/flutter/flet_flashlight/README.md +0 -3
  26. flet_flashlight-0.1.0.dev1/src/flutter/flet_flashlight/lib/flet_flashlight.dart +0 -3
  27. flet_flashlight-0.1.0.dev1/src/flutter/flet_flashlight/lib/src/create_control.dart +0 -20
  28. flet_flashlight-0.1.0.dev1/src/flutter/flet_flashlight/lib/src/flashlight.dart +0 -62
  29. {flet_flashlight-0.1.0.dev1 → flet_flashlight-0.70.0.dev6611}/setup.cfg +0 -0
  30. {flet_flashlight-0.1.0.dev1 → flet_flashlight-0.70.0.dev6611}/src/flet_flashlight.egg-info/dependency_links.txt +0 -0
  31. {flet_flashlight-0.1.0.dev1 → flet_flashlight-0.70.0.dev6611}/src/flet_flashlight.egg-info/top_level.txt +0 -0
@@ -198,4 +198,4 @@
198
198
  distributed under the License is distributed on an "AS IS" BASIS,
199
199
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
200
  See the License for the specific language governing permissions and
201
- limitations under the License.
201
+ limitations under the License.
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: flet-flashlight
3
+ Version: 0.70.0.dev6611
4
+ Summary: Control device torch/flashlight from Flet apps.
5
+ Author-email: Flet contributors <hello@flet.dev>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://flet.dev
8
+ Project-URL: Documentation, https://docs.flet.dev/flashlight
9
+ Project-URL: Repository, https://github.com/flet-dev/flet/tree/main/sdk/python/packages/flet-flashlight
10
+ Project-URL: Issues, https://github.com/flet-dev/flet/issues
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: flet==0.70.0.dev6611
15
+ Dynamic: license-file
16
+
17
+ # flet-flashlight
18
+
19
+ [![pypi](https://img.shields.io/pypi/v/flet-flashlight.svg)](https://pypi.python.org/pypi/flet-flashlight)
20
+ [![downloads](https://static.pepy.tech/badge/flet-flashlight/month)](https://pepy.tech/project/flet-flashlight)
21
+ [![license](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet-flashlight/LICENSE)
22
+
23
+ A [Flet](https://flet.dev) extension to manage the device torch/flashlight.
24
+
25
+ It is based on the [flashlight](https://pub.dev/packages/flashlight) Flutter package.
26
+
27
+ > **Important:** Add `Flashlight` instances to `page.services` before calling toggle or other methods.
28
+
29
+ ## Documentation
30
+
31
+ Detailed documentation to this package can be found [here](https://docs.flet.dev/flashlight/).
32
+
33
+ ## Platform Support
34
+
35
+ | Platform | Windows | macOS | Linux | iOS | Android | Web |
36
+ |----------|---------|-------|-------|-----|---------|-----|
37
+ | Supported| ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
38
+
39
+ ## Usage
40
+
41
+ ### Installation
42
+
43
+ To install the `flet-flashlight` package and add it to your project dependencies:
44
+
45
+ - Using `uv`:
46
+ ```bash
47
+ uv add flet-flashlight
48
+ ```
49
+
50
+ - Using `pip`:
51
+ ```bash
52
+ pip install flet-flashlight
53
+ ```
54
+ After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`.
55
+
56
+ ### Examples
57
+
58
+ For examples, see [these](https://github.com/flet-dev/flet/tree/main/examples/controls/flashlight).
@@ -0,0 +1,42 @@
1
+ # flet-flashlight
2
+
3
+ [![pypi](https://img.shields.io/pypi/v/flet-flashlight.svg)](https://pypi.python.org/pypi/flet-flashlight)
4
+ [![downloads](https://static.pepy.tech/badge/flet-flashlight/month)](https://pepy.tech/project/flet-flashlight)
5
+ [![license](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet-flashlight/LICENSE)
6
+
7
+ A [Flet](https://flet.dev) extension to manage the device torch/flashlight.
8
+
9
+ It is based on the [flashlight](https://pub.dev/packages/flashlight) Flutter package.
10
+
11
+ > **Important:** Add `Flashlight` instances to `page.services` before calling toggle or other methods.
12
+
13
+ ## Documentation
14
+
15
+ Detailed documentation to this package can be found [here](https://docs.flet.dev/flashlight/).
16
+
17
+ ## Platform Support
18
+
19
+ | Platform | Windows | macOS | Linux | iOS | Android | Web |
20
+ |----------|---------|-------|-------|-----|---------|-----|
21
+ | Supported| ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
22
+
23
+ ## Usage
24
+
25
+ ### Installation
26
+
27
+ To install the `flet-flashlight` package and add it to your project dependencies:
28
+
29
+ - Using `uv`:
30
+ ```bash
31
+ uv add flet-flashlight
32
+ ```
33
+
34
+ - Using `pip`:
35
+ ```bash
36
+ pip install flet-flashlight
37
+ ```
38
+ After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`.
39
+
40
+ ### Examples
41
+
42
+ For examples, see [these](https://github.com/flet-dev/flet/tree/main/examples/controls/flashlight).
@@ -0,0 +1,24 @@
1
+ [project]
2
+ name = "flet-flashlight"
3
+ version = "0.70.0.dev6611"
4
+ description = "Control device torch/flashlight from Flet apps."
5
+ readme = "README.md"
6
+ authors = [{ name = "Flet contributors", email = "hello@flet.dev" }]
7
+ license = "Apache-2.0"
8
+ requires-python = ">=3.10"
9
+ dependencies = [
10
+ "flet==0.70.0.dev6611",
11
+ ]
12
+
13
+ [project.urls]
14
+ Homepage = "https://flet.dev"
15
+ Documentation = "https://docs.flet.dev/flashlight"
16
+ Repository = "https://github.com/flet-dev/flet/tree/main/sdk/python/packages/flet-flashlight"
17
+ Issues = "https://github.com/flet-dev/flet/issues"
18
+
19
+ [tool.setuptools.package-data]
20
+ "flutter.flet_flashlight" = ["**/*"]
21
+
22
+ [build-system]
23
+ requires = ["setuptools"]
24
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,21 @@
1
+ from .exceptions import (
2
+ FlashlightDisableException,
3
+ FlashlightDisableExistentUserException,
4
+ FlashlightDisableNotAvailableException,
5
+ FlashlightEnableException,
6
+ FlashlightEnableExistentUserException,
7
+ FlashlightEnableNotAvailableException,
8
+ FlashlightException,
9
+ )
10
+ from .flashlight import Flashlight
11
+
12
+ __all__ = [
13
+ "Flashlight",
14
+ "FlashlightDisableException",
15
+ "FlashlightDisableExistentUserException",
16
+ "FlashlightDisableNotAvailableException",
17
+ "FlashlightEnableException",
18
+ "FlashlightEnableExistentUserException",
19
+ "FlashlightEnableNotAvailableException",
20
+ "FlashlightException",
21
+ ]
@@ -0,0 +1,65 @@
1
+ __all__ = [
2
+ "FlashlightDisableException",
3
+ "FlashlightDisableExistentUserException",
4
+ "FlashlightDisableNotAvailableException",
5
+ "FlashlightEnableException",
6
+ "FlashlightEnableExistentUserException",
7
+ "FlashlightEnableNotAvailableException",
8
+ "FlashlightException",
9
+ ]
10
+
11
+
12
+ class FlashlightException(Exception):
13
+ """
14
+ Base class for all [`Flashlight`][(p).] exceptions.
15
+
16
+ See these subclasses:
17
+ - [`FlashlightEnableExistentUserException`][(p).]
18
+ - [`FlashlightEnableNotAvailableException`][(p).]
19
+ - [`FlashlightEnableException`][(p).]
20
+ - [`FlashlightDisableExistentUserException`][(p).]
21
+ - [`FlashlightDisableNotAvailableException`][(p).]
22
+ - [`FlashlightDisableException`][(p).]
23
+ """
24
+
25
+
26
+ class FlashlightEnableExistentUserException(FlashlightException):
27
+ """
28
+ An attempt was made to turn on the torch
29
+ but it was detected that the camera was being used by another process.
30
+ This means that the torch cannot be controlled.
31
+ """
32
+
33
+
34
+ class FlashlightEnableNotAvailableException(FlashlightException):
35
+ """
36
+ An attempt was made to turn on the torch
37
+ but it was detected that the device does not have one equipped.
38
+ """
39
+
40
+
41
+ class FlashlightEnableException(FlashlightException):
42
+ """
43
+ An error occurred while trying to turn on the device torch.
44
+ """
45
+
46
+
47
+ class FlashlightDisableExistentUserException(FlashlightException):
48
+ """
49
+ An attempt was made to turn off the torch
50
+ but it was detected that the camera was being used by another process.
51
+ This means that the torch cannot be controlled.
52
+ """
53
+
54
+
55
+ class FlashlightDisableNotAvailableException(FlashlightException):
56
+ """
57
+ An attempt was made to turn off the torch,
58
+ but it was detected that the device does not have one equipped.
59
+ """
60
+
61
+
62
+ class FlashlightDisableException(FlashlightException):
63
+ """
64
+ An error occurred while trying to turn off the device torch.
65
+ """
@@ -0,0 +1,89 @@
1
+ from typing import Optional
2
+
3
+ import flet as ft
4
+
5
+ from .exceptions import (
6
+ FlashlightDisableException,
7
+ FlashlightDisableExistentUserException,
8
+ FlashlightDisableNotAvailableException,
9
+ FlashlightEnableException,
10
+ FlashlightEnableExistentUserException,
11
+ FlashlightEnableNotAvailableException,
12
+ FlashlightException,
13
+ )
14
+
15
+ __all__ = ["Flashlight"]
16
+
17
+
18
+ @ft.control("Flashlight")
19
+ class Flashlight(ft.Service):
20
+ """
21
+ A control to use FlashLight. Works on iOS and Android.
22
+ """
23
+
24
+ on = False
25
+ """
26
+ Whether the flashlight is currently turned on.
27
+ """
28
+
29
+ on_error: Optional[ft.ControlEventHandler["Flashlight"]] = None
30
+ """
31
+ Fires when an error occurs.
32
+
33
+ The [`data`][flet.Event.data] property of the event handler argument
34
+ contains information on the error.
35
+ """
36
+
37
+ async def turn_on(self):
38
+ """
39
+ Turns the flashlight on.
40
+ """
41
+ r = await self._invoke_method("on")
42
+ if r is True:
43
+ self.on = True
44
+ else: # error occured
45
+ error_type = r.get("error_type")
46
+ error_msg = r.get("error_msg")
47
+ if error_type == "EnableTorchExistentUserException":
48
+ raise FlashlightEnableExistentUserException(error_msg)
49
+ elif error_type == "EnableTorchNotAvailableException":
50
+ raise FlashlightEnableNotAvailableException(error_msg)
51
+ else:
52
+ raise FlashlightEnableException(error_msg)
53
+
54
+ async def turn_off(self):
55
+ """
56
+ Turns the flashlight off.
57
+ """
58
+ r = await self._invoke_method("off")
59
+ if r is True:
60
+ self.on = False
61
+ else: # error occured
62
+ error_type = r.get("error_type")
63
+ error_msg = r.get("error_msg")
64
+ if error_type == "DisableTorchExistentUserException":
65
+ raise FlashlightDisableExistentUserException(error_msg)
66
+ elif error_type == "DisableTorchNotAvailableException":
67
+ raise FlashlightDisableNotAvailableException(error_msg)
68
+ else:
69
+ raise FlashlightDisableException(error_msg)
70
+
71
+ async def toggle(self):
72
+ """
73
+ Toggles the flashlight on and off.
74
+ """
75
+ if self.on:
76
+ await self.turn_off()
77
+ else:
78
+ await self.turn_on()
79
+
80
+ async def is_available(self):
81
+ """
82
+ Checks if the flashlight is available on the device.
83
+ """
84
+ r = await self._invoke_method("is_available")
85
+ if isinstance(r, bool):
86
+ return r
87
+ else: # error occured
88
+ error_msg = r.get("error_msg")
89
+ raise FlashlightException(error_msg)
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: flet-flashlight
3
+ Version: 0.70.0.dev6611
4
+ Summary: Control device torch/flashlight from Flet apps.
5
+ Author-email: Flet contributors <hello@flet.dev>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://flet.dev
8
+ Project-URL: Documentation, https://docs.flet.dev/flashlight
9
+ Project-URL: Repository, https://github.com/flet-dev/flet/tree/main/sdk/python/packages/flet-flashlight
10
+ Project-URL: Issues, https://github.com/flet-dev/flet/issues
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: flet==0.70.0.dev6611
15
+ Dynamic: license-file
16
+
17
+ # flet-flashlight
18
+
19
+ [![pypi](https://img.shields.io/pypi/v/flet-flashlight.svg)](https://pypi.python.org/pypi/flet-flashlight)
20
+ [![downloads](https://static.pepy.tech/badge/flet-flashlight/month)](https://pepy.tech/project/flet-flashlight)
21
+ [![license](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet-flashlight/LICENSE)
22
+
23
+ A [Flet](https://flet.dev) extension to manage the device torch/flashlight.
24
+
25
+ It is based on the [flashlight](https://pub.dev/packages/flashlight) Flutter package.
26
+
27
+ > **Important:** Add `Flashlight` instances to `page.services` before calling toggle or other methods.
28
+
29
+ ## Documentation
30
+
31
+ Detailed documentation to this package can be found [here](https://docs.flet.dev/flashlight/).
32
+
33
+ ## Platform Support
34
+
35
+ | Platform | Windows | macOS | Linux | iOS | Android | Web |
36
+ |----------|---------|-------|-------|-----|---------|-----|
37
+ | Supported| ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
38
+
39
+ ## Usage
40
+
41
+ ### Installation
42
+
43
+ To install the `flet-flashlight` package and add it to your project dependencies:
44
+
45
+ - Using `uv`:
46
+ ```bash
47
+ uv add flet-flashlight
48
+ ```
49
+
50
+ - Using `pip`:
51
+ ```bash
52
+ pip install flet-flashlight
53
+ ```
54
+ After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`.
55
+
56
+ ### Examples
57
+
58
+ For examples, see [these](https://github.com/flet-dev/flet/tree/main/examples/controls/flashlight).
@@ -1,18 +1,17 @@
1
+ LICENSE
1
2
  README.md
2
3
  pyproject.toml
3
4
  src/flet_flashlight/__init__.py
5
+ src/flet_flashlight/exceptions.py
4
6
  src/flet_flashlight/flashlight.py
5
7
  src/flet_flashlight.egg-info/PKG-INFO
6
8
  src/flet_flashlight.egg-info/SOURCES.txt
7
9
  src/flet_flashlight.egg-info/dependency_links.txt
8
10
  src/flet_flashlight.egg-info/requires.txt
9
11
  src/flet_flashlight.egg-info/top_level.txt
10
- src/flutter/flet_flashlight/CHANGELOG.md
11
- src/flutter/flet_flashlight/LICENSE
12
- src/flutter/flet_flashlight/README.md
13
12
  src/flutter/flet_flashlight/analysis_options.yaml
14
13
  src/flutter/flet_flashlight/pubspec.lock
15
14
  src/flutter/flet_flashlight/pubspec.yaml
16
15
  src/flutter/flet_flashlight/lib/flet_flashlight.dart
17
- src/flutter/flet_flashlight/lib/src/create_control.dart
16
+ src/flutter/flet_flashlight/lib/src/extension.dart
18
17
  src/flutter/flet_flashlight/lib/src/flashlight.dart
@@ -0,0 +1 @@
1
+ flet==0.70.0.dev6611
@@ -2,4 +2,4 @@ include: package:flutter_lints/flutter.yaml
2
2
 
3
3
 
4
4
  # Additional information about this file can be found at
5
- # https://dart.dev/guides/language/analysis-options
5
+ # https://dart.dev/guides/language/analysis-options
@@ -0,0 +1,3 @@
1
+ library flet_flashlight;
2
+
3
+ export 'src/extension.dart' show Extension;
@@ -0,0 +1,15 @@
1
+ import 'package:flet/flet.dart';
2
+
3
+ import 'flashlight.dart';
4
+
5
+ class Extension extends FletExtension {
6
+ @override
7
+ FletService? createService(Control control) {
8
+ switch (control.type) {
9
+ case "Flashlight":
10
+ return FlashlightControl(control: control);
11
+ default:
12
+ return null;
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,101 @@
1
+ import 'package:flet/flet.dart';
2
+ import 'package:flutter/widgets.dart';
3
+ import 'package:torch_light/torch_light.dart';
4
+
5
+ class FlashlightControl extends FletService {
6
+ FlashlightControl({required super.control});
7
+
8
+ @override
9
+ void init() {
10
+ super.init();
11
+ debugPrint("Flashlight(${control.id}).init: ${control.properties}");
12
+ control.addInvokeMethodListener(_invokeMethod);
13
+ }
14
+
15
+ Future<dynamic> _invokeMethod(String name, dynamic args) async {
16
+ debugPrint("Flashlight.$name($args)");
17
+ if (isMobilePlatform()) {
18
+ Map<String, String?>? errorInfo;
19
+ switch (name) {
20
+ case "on":
21
+ try {
22
+ await TorchLight.enableTorch();
23
+ return true;
24
+ } catch (e) {
25
+ if (e is EnableTorchExistentUserException) {
26
+ errorInfo = {
27
+ "error_type": "EnableTorchExistentUserException",
28
+ "error_msg": e.message
29
+ };
30
+ } else if (e is EnableTorchNotAvailableException) {
31
+ errorInfo = {
32
+ "error_type": "EnableTorchNotAvailableException",
33
+ "error_msg": e.message
34
+ };
35
+ } else {
36
+ errorInfo = {
37
+ "error_type": "EnableTorchException",
38
+ "error_msg": (e as EnableTorchException).message
39
+ };
40
+ }
41
+ control.triggerEvent("error", errorInfo);
42
+ debugPrint(
43
+ "Error enabling Flashlight: ${errorInfo["error_type"]}(${errorInfo["error_msg"]})");
44
+ return errorInfo;
45
+ }
46
+ case "off":
47
+ try {
48
+ await TorchLight.disableTorch();
49
+ return true;
50
+ } catch (e) {
51
+ if (e is DisableTorchExistentUserException) {
52
+ errorInfo = {
53
+ "error_type": "DisableTorchExistentUserException",
54
+ "error_msg": e.message
55
+ };
56
+ } else if (e is DisableTorchNotAvailableException) {
57
+ errorInfo = {
58
+ "error_type": "DisableTorchNotAvailableException",
59
+ "error_msg": e.message
60
+ };
61
+ } else {
62
+ errorInfo = {
63
+ "error_type": "DisableTorchException",
64
+ "error_msg": (e as DisableTorchException).message
65
+ };
66
+ }
67
+ control.triggerEvent("error", errorInfo);
68
+ debugPrint(
69
+ "Error disabling Flashlight: ${errorInfo["error_type"]}(${errorInfo["error_msg"]})");
70
+ return errorInfo;
71
+ }
72
+ case "is_available":
73
+ try {
74
+ final available = await TorchLight.isTorchAvailable();
75
+ return available;
76
+ } on EnableTorchException catch (e) {
77
+ errorInfo = {
78
+ "error_type": "EnableTorchException",
79
+ "error_msg": e.message
80
+ };
81
+ control.triggerEvent("error", errorInfo);
82
+ debugPrint(
83
+ "Error checking Flashlight availability: EnableTorchException(${e.message})");
84
+ return errorInfo;
85
+ }
86
+ default:
87
+ throw Exception("Unknown Flashlight method: $name");
88
+ }
89
+ } else {
90
+ throw Exception(
91
+ "Flashlight control is supported only on Android and iOS devices.");
92
+ }
93
+ }
94
+
95
+ @override
96
+ void dispose() {
97
+ debugPrint("Flashlight(${control.id}).dispose");
98
+ control.removeInvokeMethodListener(_invokeMethod);
99
+ super.dispose();
100
+ }
101
+ }