flet-permission-handler 0.1.0.dev1__py3-none-any.whl → 0.70.0.dev6611__py3-none-any.whl
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-permission-handler might be problematic. Click here for more details.
- flet_permission_handler/__init__.py +8 -5
- flet_permission_handler/permission_handler.py +72 -133
- flet_permission_handler/types.py +425 -0
- flet_permission_handler-0.70.0.dev6611.dist-info/METADATA +61 -0
- flet_permission_handler-0.70.0.dev6611.dist-info/RECORD +15 -0
- {flet_permission_handler-0.1.0.dev1.dist-info → flet_permission_handler-0.70.0.dev6611.dist-info}/WHEEL +1 -1
- {flutter/flet_permission_handler → flet_permission_handler-0.70.0.dev6611.dist-info/licenses}/LICENSE +1 -1
- flutter/flet_permission_handler/lib/flet_permission_handler.dart +1 -1
- flutter/flet_permission_handler/lib/src/extension.dart +15 -0
- flutter/flet_permission_handler/lib/src/permission_handler.dart +31 -60
- flutter/flet_permission_handler/lib/src/utils/permission_handler.dart +4 -8
- flutter/flet_permission_handler/pubspec.lock +212 -149
- flutter/flet_permission_handler/pubspec.yaml +12 -8
- flet_permission_handler-0.1.0.dev1.dist-info/METADATA +0 -69
- flet_permission_handler-0.1.0.dev1.dist-info/RECORD +0 -16
- flutter/flet_permission_handler/CHANGELOG.md +0 -3
- flutter/flet_permission_handler/README.md +0 -3
- flutter/flet_permission_handler/lib/src/create_control.dart +0 -17
- {flet_permission_handler-0.1.0.dev1.dist-info → flet_permission_handler-0.70.0.dev6611.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flet-permission-handler
|
|
3
|
+
Version: 0.70.0.dev6611
|
|
4
|
+
Summary: Manage runtime permissions in 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/permission-handler
|
|
9
|
+
Project-URL: Repository, https://github.com/flet-dev/flet/tree/main/sdk/python/packages/flet-permission-handler
|
|
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-permission-handler
|
|
18
|
+
|
|
19
|
+
[](https://pypi.python.org/pypi/flet-permission-handler)
|
|
20
|
+
[](https://pepy.tech/project/flet-permission-handler)
|
|
21
|
+
[](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet-permission-handler/LICENSE)
|
|
22
|
+
|
|
23
|
+
A [Flet](https://flet.dev) extension that simplifies working with device permissions.
|
|
24
|
+
|
|
25
|
+
It is based on the [permission_handler](https://pub.dev/packages/permission_handler) Flutter package
|
|
26
|
+
and brings similar functionality to Flet, including:
|
|
27
|
+
|
|
28
|
+
- Requesting permissions at runtime
|
|
29
|
+
- Checking the current permission status (e.g., granted, denied)
|
|
30
|
+
- Redirecting users to system settings to manually grant permissions
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
Detailed documentation to this package can be found [here](https://docs.flet.dev/permission-handler/).
|
|
35
|
+
|
|
36
|
+
## Platform Support
|
|
37
|
+
|
|
38
|
+
| Platform | Windows | macOS | Linux | iOS | Android | Web |
|
|
39
|
+
|----------|---------|-------|-------|-----|---------|-----|
|
|
40
|
+
| Supported| ✅ | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Installation
|
|
45
|
+
|
|
46
|
+
To install the `flet-permission-handler` package and add it to your project dependencies:
|
|
47
|
+
|
|
48
|
+
- Using `uv`:
|
|
49
|
+
```bash
|
|
50
|
+
uv add flet-permission-handler
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- Using `pip`:
|
|
54
|
+
```bash
|
|
55
|
+
pip install flet-permission-handler
|
|
56
|
+
```
|
|
57
|
+
After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`.
|
|
58
|
+
|
|
59
|
+
### Examples
|
|
60
|
+
|
|
61
|
+
For examples, see [these](https://github.com/flet-dev/flet/tree/main/sdk/python/examples/controls/permission_handler).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
flet_permission_handler/__init__.py,sha256=VYdjSU5NV0Pz4pZn4KhMDLI8eKiV4xsqjkEHvhr4v3s,226
|
|
2
|
+
flet_permission_handler/permission_handler.py,sha256=nUG05Zwxv50Fig9iu0L3gmEo9uoXMPqDq07ynxoRXa8,2495
|
|
3
|
+
flet_permission_handler/types.py,sha256=sM1d6El9OredybfSV9u4-0loarRdKRRA7vV1VIuvw7w,11292
|
|
4
|
+
flet_permission_handler-0.70.0.dev6611.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
5
|
+
flutter/flet_permission_handler/analysis_options.yaml,sha256=32kjGAc-zF87inWaH5M46yGZWQDTwrwfvNLHeAocfG4,154
|
|
6
|
+
flutter/flet_permission_handler/pubspec.lock,sha256=Xc6zp0Icc1ag69eAXCuqtvW1F94SXcaIS48QN-LjYl4,24768
|
|
7
|
+
flutter/flet_permission_handler/pubspec.yaml,sha256=yQHXz3NMHBH4L3d_AUyuuhnKLY-KtUEjq18KBtmnsUw,392
|
|
8
|
+
flutter/flet_permission_handler/lib/flet_permission_handler.dart,sha256=rrlbNta1UlnSvzwOJsAUmOHvEBjfUDvMo6jnZQIO67s,78
|
|
9
|
+
flutter/flet_permission_handler/lib/src/extension.dart,sha256=FYygqTMesWQOUIIf6dLmZS98gCVE_3KmccdR2_LTDg0,336
|
|
10
|
+
flutter/flet_permission_handler/lib/src/permission_handler.dart,sha256=5aBWHNUIczDmmbsbXzzzB79vIbpDVpBAxo281_ghkss,1395
|
|
11
|
+
flutter/flet_permission_handler/lib/src/utils/permission_handler.dart,sha256=EL5W_CCK8nxeQum4UmN7IU1R5J9Seg3xZBYMLRogCOU,405
|
|
12
|
+
flet_permission_handler-0.70.0.dev6611.dist-info/METADATA,sha256=SAfd0yb2gc8aQSrAuQf-AfjKMUiBdznhc8rN1i1wkwg,2337
|
|
13
|
+
flet_permission_handler-0.70.0.dev6611.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
+
flet_permission_handler-0.70.0.dev6611.dist-info/top_level.txt,sha256=GMsa0IlcchYQqCgGn8WkekKbU0cb5k8lCazopnbWU_s,32
|
|
15
|
+
flet_permission_handler-0.70.0.dev6611.dist-info/RECORD,,
|
|
@@ -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,15 @@
|
|
|
1
|
+
import 'package:flet/flet.dart';
|
|
2
|
+
|
|
3
|
+
import 'permission_handler.dart';
|
|
4
|
+
|
|
5
|
+
class Extension extends FletExtension {
|
|
6
|
+
@override
|
|
7
|
+
FletService? createService(Control control) {
|
|
8
|
+
switch (control.type) {
|
|
9
|
+
case "PermissionHandler":
|
|
10
|
+
return PermissionHandlerService(control: control);
|
|
11
|
+
default:
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -4,72 +4,43 @@ import 'package:permission_handler/permission_handler.dart';
|
|
|
4
4
|
|
|
5
5
|
import 'utils/permission_handler.dart';
|
|
6
6
|
|
|
7
|
-
class
|
|
8
|
-
|
|
9
|
-
final Control control;
|
|
10
|
-
final FletControlBackend backend;
|
|
7
|
+
class PermissionHandlerService extends FletService {
|
|
8
|
+
PermissionHandlerService({required super.control});
|
|
11
9
|
|
|
12
|
-
const PermissionHandlerControl(
|
|
13
|
-
{super.key,
|
|
14
|
-
required this.parent,
|
|
15
|
-
required this.control,
|
|
16
|
-
required this.backend});
|
|
17
|
-
|
|
18
|
-
@override
|
|
19
|
-
State<PermissionHandlerControl> createState() =>
|
|
20
|
-
_PermissionHandlerControlState();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
class _PermissionHandlerControlState extends State<PermissionHandlerControl>
|
|
24
|
-
with FletStoreMixin {
|
|
25
10
|
@override
|
|
26
|
-
void
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
super.initState();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
void _onRemove() {
|
|
34
|
-
debugPrint("PermissionHandler.remove($hashCode)");
|
|
35
|
-
widget.backend.unsubscribeMethods(widget.control.id);
|
|
11
|
+
void init() {
|
|
12
|
+
super.init();
|
|
13
|
+
debugPrint("PermissionHandler(${control.id}).init: ${control.properties}");
|
|
14
|
+
control.addInvokeMethodListener(_invokeMethod);
|
|
36
15
|
}
|
|
37
16
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
Future<dynamic> _invokeMethod(String name, dynamic args) async {
|
|
18
|
+
debugPrint("PermissionHandler.$name($args)");
|
|
19
|
+
switch (name) {
|
|
20
|
+
case "get_status":
|
|
21
|
+
return await parsePermission(args['permission'])?.status.then((value) {
|
|
22
|
+
return value.name;
|
|
23
|
+
});
|
|
24
|
+
case "request":
|
|
25
|
+
var permission = parsePermission(args['permission']);
|
|
26
|
+
if (permission != null) {
|
|
27
|
+
Future<PermissionStatus> status = permission.request();
|
|
28
|
+
return await status.then((value) async {
|
|
29
|
+
return value.name;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
case "open_app_settings":
|
|
34
|
+
return await openAppSettings();
|
|
35
|
+
default:
|
|
36
|
+
throw Exception("Unknown PermissionHandler method: $name");
|
|
37
|
+
}
|
|
42
38
|
}
|
|
43
39
|
|
|
44
40
|
@override
|
|
45
|
-
|
|
46
|
-
debugPrint("PermissionHandler
|
|
47
|
-
|
|
48
|
-
()
|
|
49
|
-
widget.backend.subscribeMethods(widget.control.id,
|
|
50
|
-
(methodName, args) async {
|
|
51
|
-
switch (methodName) {
|
|
52
|
-
case "check_permission":
|
|
53
|
-
return await parsePermission(args['of'])?.status.then((value) {
|
|
54
|
-
debugPrint("PermissionHandler.check_permission: $value");
|
|
55
|
-
return value.name;
|
|
56
|
-
});
|
|
57
|
-
case "request_permission":
|
|
58
|
-
var p = parsePermission(args['of']);
|
|
59
|
-
if (p != null) {
|
|
60
|
-
Future<PermissionStatus> permissionStatus = p.request();
|
|
61
|
-
return await permissionStatus.then((value) async {
|
|
62
|
-
return value.name;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
case "open_app_settings":
|
|
67
|
-
return await openAppSettings().then((value) => value.toString());
|
|
68
|
-
}
|
|
69
|
-
return null;
|
|
70
|
-
});
|
|
71
|
-
}();
|
|
72
|
-
|
|
73
|
-
return const SizedBox.shrink();
|
|
41
|
+
void dispose() {
|
|
42
|
+
debugPrint("PermissionHandler(${control.id}).dispose()");
|
|
43
|
+
control.removeInvokeMethodListener(_invokeMethod);
|
|
44
|
+
super.dispose();
|
|
74
45
|
}
|
|
75
46
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import "package:collection/collection.dart";
|
|
2
2
|
import "package:permission_handler/permission_handler.dart";
|
|
3
3
|
|
|
4
|
-
Permission? parsePermission(String?
|
|
5
|
-
|
|
6
|
-
if (permission == null) {
|
|
7
|
-
return defaultPermission;
|
|
8
|
-
}
|
|
4
|
+
Permission? parsePermission(String? value, [Permission? defaultValue]) {
|
|
5
|
+
if (value == null) return defaultValue;
|
|
9
6
|
return Permission.values.firstWhereOrNull(
|
|
10
7
|
(Permission p) =>
|
|
11
|
-
p.toString().split('.').last.toLowerCase() ==
|
|
12
|
-
permission.toLowerCase(),
|
|
8
|
+
p.toString().split('.').last.toLowerCase() == value.toLowerCase(),
|
|
13
9
|
) ??
|
|
14
|
-
|
|
10
|
+
defaultValue;
|
|
15
11
|
}
|