Permission Handler#
Manage runtime permissions in your Flet apps using the flet-permission-handler extension, powered by Flutter's permission_handler.
Platform Support#
| Platform | Windows | macOS | Linux | iOS | Android | Web | 
|---|---|---|---|---|---|---|
| Supported | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | 
Usage#
Add flet-permission-handler to your project dependencies:
Note
On mobile platforms you must also declare permissions in the native project files. See Flet publish docs.
Example#
import flet_permission_handler as fph
import flet as ft
def main(page: ft.Page):
    page.appbar = ft.AppBar(title="PermissionHandler Playground")
    def show_snackbar(message: str):
        page.show_dialog(ft.SnackBar(ft.Text(message)))
    async def get_permission_status(e: ft.Event[ft.OutlinedButton]):
        status = await ph.get_status(fph.Permission.MICROPHONE)
        show_snackbar(f"Microphone permission status: {status.name}")
    async def request_permission(e: ft.Event[ft.OutlinedButton]):
        status = await ph.request(fph.Permission.MICROPHONE)
        show_snackbar(f"Requested microphone permission: {status.name}")
    async def open_app_settings(e: ft.Event[ft.OutlinedButton]):
        show_snackbar("Opening app settings...")
        await ph.open_app_settings()
    ph = fph.PermissionHandler()
    page.add(
        ft.OutlinedButton("Open app settings", on_click=open_app_settings),
        ft.OutlinedButton("Request Microphone permission", on_click=request_permission),
        ft.OutlinedButton(
            "Get Microphone permission status", on_click=get_permission_status
        ),
    )
ft.run(main)
Description#
        Inherits: Service
Manages permissions for the application.
Platform support
Currently only supported on Android, iOS, Windows, and Web platforms.
Raises:
- 
              FletUnsupportedPlatformException–If the platform is not supported. 
Methods
- 
            get_status–Gets the current status of the given permission.
- 
            open_app_settings–Opens the app settings page. 
- 
            request–Request the user for access to the permissionif access hasn't already been
Methods#
async
  
#
get_status(
    permission: Permission,
) -> PermissionStatus | None
Gets the current status of the given permission.
Parameters:
- 
            permission(Permission) –The Permissionto check the status for.
Returns:
- 
              PermissionStatus | None–A PermissionStatusif the status is known, otherwiseNone.
async
  
#
open_app_settings() -> bool
Opens the app settings page.
Returns:
- 
              bool–Trueif the app settings page could be opened, otherwiseFalse.
async
  
#
request(permission: Permission) -> PermissionStatus | None
Request the user for access to the permission if access hasn't already been
granted access before.
Parameters:
- 
            permission(Permission) –The Permissionto request.
Returns:
- 
              PermissionStatus | None–The new PermissionStatusafter the request, orNoneif the request was not successful.