|
1 |
| -# PermissionHandler control for Flet |
| 1 | +# flet-permission-handler |
2 | 2 |
|
3 |
| -`PermissionHandler` control for Flet. |
| 3 | +[](https://pypi.python.org/pypi/flet-permission-handler) |
| 4 | +[](https://pepy.tech/project/flet-permission-handler) |
| 5 | +[](https://github.com/flet-dev/flet-permission-handler/blob/main/LICENSE) |
4 | 6 |
|
5 |
| -## Usage |
| 7 | +A [Flet](https://flet.dev) extension that simplifies working with device permissions. |
6 | 8 |
|
7 |
| -Add `flet-permission-handler` as dependency (`pyproject.toml` or `requirements.txt`) to your Flet project. |
| 9 | +It is based on the [permission_handler](https://pub.dev/packages/permission_handler) Flutter package |
| 10 | +and brings similar functionality to Flet, including: |
8 | 11 |
|
9 |
| -## Example |
| 12 | +- Requesting permissions at runtime |
| 13 | +- Checking the current permission status (e.g., granted, denied) |
| 14 | +- Redirecting users to system settings to manually grant permissions |
10 | 15 |
|
11 |
| -```py |
| 16 | +## Documentation |
12 | 17 |
|
13 |
| -import flet as ft |
| 18 | +Detailed documentation to this package can be found [here](https://flet-dev.github.io/flet-permission-handler/). |
14 | 19 |
|
15 |
| -import flet_permission_handler as fph |
| 20 | +## Platform Support |
16 | 21 |
|
| 22 | +This package supports the following platforms: |
17 | 23 |
|
18 |
| -def main(page: ft.Page): |
19 |
| - page.scroll = ft.ScrollMode.ADAPTIVE |
20 |
| - page.appbar = ft.AppBar(title=ft.Text("PermissionHandler Tests")) |
21 |
| - ph = fph.PermissionHandler() |
22 |
| - page.overlay.append(ph) |
| 24 | +| Platform | Supported | |
| 25 | +|----------|:---------:| |
| 26 | +| Windows | ✅ | |
| 27 | +| macOS | ❌ | |
| 28 | +| Linux | ❌ | |
| 29 | +| iOS | ✅ | |
| 30 | +| Android | ✅ | |
| 31 | +| Web | ✅ | |
23 | 32 |
|
24 |
| - def check_permission(e): |
25 |
| - o = ph.check_permission(e.control.data) |
26 |
| - page.add(ft.Text(f"Checked {e.control.data.name}: {o}")) |
| 33 | +## Installation |
27 | 34 |
|
28 |
| - def request_permission(e): |
29 |
| - o = ph.request_permission(e.control.data) |
30 |
| - page.add(ft.Text(f"Requested {e.control.data.name}: {o}")) |
| 35 | +To install the `flet-permission-handler` package and add it to your project dependencies: |
31 | 36 |
|
32 |
| - def open_app_settings(e): |
33 |
| - o = ph.open_app_settings() |
34 |
| - page.add(ft.Text(f"App Settings: {o}")) |
| 37 | +- Using `uv`: |
| 38 | + ```bash |
| 39 | + uv add flet-permission-handler |
| 40 | + ``` |
35 | 41 |
|
36 |
| - page.add( |
37 |
| - ft.OutlinedButton( |
38 |
| - "Check Microphone Permission", |
39 |
| - data=fph.PermissionType.MICROPHONE, |
40 |
| - on_click=check_permission, |
41 |
| - ), |
42 |
| - ft.OutlinedButton( |
43 |
| - "Request Microphone Permission", |
44 |
| - data=fph.PermissionType.MICROPHONE, |
45 |
| - on_click=request_permission, |
46 |
| - ), |
47 |
| - ft.OutlinedButton( |
48 |
| - "Open App Settings", |
49 |
| - on_click=open_app_settings, |
50 |
| - ), |
51 |
| - ) |
| 42 | +- Using `pip`: |
| 43 | + ```bash |
| 44 | + pip install flet-permission-handler |
| 45 | + ``` |
| 46 | + After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`. |
52 | 47 |
|
| 48 | +- Using `poetry`: |
| 49 | + ```bash |
| 50 | + poetry add flet-permission-handler |
| 51 | + ``` |
53 | 52 |
|
54 |
| -ft.app(main) |
55 |
| -``` |
| 53 | +## Examples |
| 54 | + |
| 55 | +For examples, see [this](./examples) |
0 commit comments