FletApp
Renders another Flet app in the current app, similar to HTML IFrame, but for Flet.
Inherits: LayoutControl
Properties
app_error_message- Template message to display when the app fails to load.args- Optional dictionary of arguments to pass to the Flet app.assets_dir- Base location for assets referenced by the embedded app.boot_screen_name- Name of the boot screen to show while the embedded app starts up.boot_screen_options- Options for the boot screen, passed through to the boot screen widget.force_pyodide- Whether to force the use of Pyodide.reconnect_interval_ms- Delay, in milliseconds, between reconnection attempts.reconnect_timeout_ms- Total time to try reconnecting.url- Flet app URL, e.g.
Events
on_connect- Fires when the client allocates an in-processdart_bridgechannel for this embedded app (url="dartbridge://").on_error- Called when a connection or any unhandled error occurs.on_python_output- Fires once per stdout/stderr write inside the embedded Pyodide app.
Methods
wait_idle- Waits until the embedded app has rendered its UI and gone quiet.
Properties
app_error_messageclass-attributeinstance-attribute
app_error_message: str | None = NoneTemplate message to display when the app fails to load.
Use {message} placeholder to include the error message
and {details} to include error details.
argsclass-attributeinstance-attribute
args: dict[str, Any] | None = NoneOptional dictionary of arguments to pass to the Flet app.
assets_dirclass-attributeinstance-attribute
assets_dir: str | None = NoneBase location for assets referenced by the embedded app. On web this
is a URL prefix joined with relative src values (e.g. on
Image/Lottie/Markdown); on desktop it is a filesystem path.
boot_screen_nameclass-attributeinstance-attribute
boot_screen_name: str | None = NoneName of the boot screen to show while the embedded app starts up.
When None, the built-in "flet" boot screen is used. Custom boot screens
are provided by extensions; see the
boot screen docs.
boot_screen_optionsclass-attributeinstance-attribute
boot_screen_options: dict[str, Any] | None = NoneOptions for the boot screen, passed through to the boot screen widget.
For the built-in "flet" screen these include spinner_size,
startup_message, bgcolor_light/bgcolor_dark, etc. See the
boot screen docs.
force_pyodideclass-attributeinstance-attribute
force_pyodide: bool = FalseWhether to force the use of Pyodide.
reconnect_interval_msclass-attributeinstance-attribute
reconnect_interval_ms: int | None = NoneDelay, in milliseconds, between reconnection attempts.
reconnect_timeout_msclass-attributeinstance-attribute
reconnect_timeout_ms: int | None = NoneTotal time to try reconnecting.
urlclass-attributeinstance-attribute
url: str | None = NoneFlet app URL, e.g. http://localhost:8550 or flet.sock.
Events
on_connectclass-attributeinstance-attribute
on_connect: ControlEventHandler[FletApp] | None = NoneFires when the client allocates an in-process dart_bridge channel for this
embedded app (url="dartbridge://"). The event data is the Dart native
port the host must serve with a FletDartBridgeServer so the embedded app
connects over it instead of a socket.
Advanced / embedder use — hosts that run another Flet program in-process (e.g. a gallery or preview) start their server on this port in the handler.
on_errorclass-attributeinstance-attribute
on_error: ControlEventHandler[FletApp] | None = NoneCalled when a connection or any unhandled error occurs.
on_python_outputclass-attributeinstance-attribute
on_python_output: (
EventHandler[FletAppOutputEvent] | None
) = NoneFires once per stdout/stderr write inside the embedded Pyodide app.
Pyodide line-buffers by default, so each event is typically one
print(...) call. Only fires for embedded FletApps with
force_pyodide=True; root-level Pyodide pages have nowhere to
bubble the event.
Methods
wait_idleasync
wait_idle(
idle_ms: int = 300, timeout_ms: int = 30000
) -> dict[str, Any]Waits until the embedded app has rendered its UI and gone quiet.
Useful for a host that needs to know when the embedded app is ready, e.g. before taking a screenshot of it or reading its output after a restart.
Parameters:
- idle_ms (int, default:
300) - How long, in milliseconds, the embedded app must send no UI updates after its first one to count as idle. - timeout_ms (int, default:
30000) - Give up after this many milliseconds.
Returns:
- dict[str, Any] - A dict with
statusanderror.statusis"idle"once the - dict[str, Any] - app sent at least one UI update, then none for
idle_ms, and - dict[str, Any] - that update is on screen;
"error"if the app failed to start - dict[str, Any] - or crashed (
errorholds the message;on_errorfires as - dict[str, Any] - well);
"timeout"if it didn't settle withintimeout_ms, for - dict[str, Any] - example an app that updates continuously. A new call supersedes
- dict[str, Any] - a pending one, which returns
"timeout".