captureRemoteDocument
public fun captureRemoteDocument(
context: Context,
creationDisplayInfo: RemoteCreationDisplayInfo,
remoteDensity: RemoteDensity =
RemoteDensity(
creationDisplayInfo.density.density.rf,
creationDisplayInfo.density.fontScale.rf,
),
layoutDirection: LayoutDirection? = null,
writerEvents: WriterEvents = WriterEvents(),
clock: RemoteClock = RemoteClock.SYSTEM,
profile: Profile = RcPlatformProfiles.ANDROIDX,
coroutineContext: CoroutineContext = Dispatchers.Default,
content: @Composable @RemoteComposable () -> Unit,
): Flow<ByteArray>
Capture a stream of RemoteCompose documents by rendering the specified content Composable in a virtual display and emitting the resulting byte arrays whenever recomposition occurs and the layout visually changes.
This API allows capturing dynamic Compose content (e.g., containing animations, transitions, or state updates) as a Flow of serialized document byte arrays.
Crucially, recomposition is handled cleanly, and duplicate documents (where nothing visually changed in the layout tree) are automatically filtered out, so new byte arrays are only emitted when the document actually changes.
Parameters
| creationDisplayInfo | Details about the virtual display to capture for (size, density, etc.). |
| remoteDensity | The logical screen density and font scale to use for unit conversions. Defaults to density derived from creationDisplayInfo. Note: If passing custom values, they should typically match the density and font scale specified in creationDisplayInfo to avoid layout scaling discrepancies. |
| layoutDirection | The layout direction (LTR or RTL) to use. Defaults to LTR. |
| writerEvents | Callback to handle non-serializable events (e.g. pending intents). |
| context | The Android Context to use. |
| clock | The clock used for the recomposer timeline. Defaults to RemoteClock.SYSTEM. |
| profile | The writing profile that determines supported operations. Defaults to RcPlatformProfiles.ANDROIDX. |
| coroutineContext | The CoroutineContext to run recomposition and rendering on. Defaults to Dispatchers.Default. |
| content | The Composable content to render and capture. |
Returns
A Flow of ByteArrays containing the serialized RemoteCompose documents. |