Skip to main content
Enable Picture-in-Picture (PiP) mode to allow users to continue their call in a floating window while using other apps. PiP provides a seamless multitasking experience during calls.
The Flutter Calls SDK provides enterPipMode() and isPipSupported() methods on CallSession to manage PiP mode. The SDK handles the PiP layout adjustments automatically when PiP is activated.

Platform Differences

PiP behavior differs between Android and iOS:
PlatformBehavior
AndroidUses the system PiP API. The call UI shrinks into a floating window managed by the OS. Requires supportsPictureInPicture in AndroidManifest.xml.
iOSUses a custom overlay approach. The call continues in a compact overlay view within the app. No additional manifest configuration required.
On Android, PiP mode is only available on Android 8.0 (API level 26) and higher. Use isPipSupported() to check availability before entering PiP mode.

Check PiP Support

Check whether the current device supports Picture-in-Picture mode:
CallSession? callSession = CallSession.getInstance();

bool? supported = await callSession?.isPipSupported();
if (supported == true) {
  debugPrint("PiP is supported on this device");
} else {
  debugPrint("PiP is not supported on this device");
}

Enter PiP Mode

Enter Picture-in-Picture mode programmatically:
CallSession? callSession = CallSession.getInstance();

bool? supported = await callSession?.isPipSupported();
if (supported == true) {
  await callSession?.enterPipMode();
}

Enable PiP Layout

You can also use the layout-level PiP methods to adjust the call UI for a PiP-sized window:
await CallSession.getInstance()?.enablePictureInPictureLayout();

Disable PiP Layout

Exit PiP layout and return to the full-screen call interface:
await CallSession.getInstance()?.disablePictureInPictureLayout();

Listen for PiP Events

Monitor PiP mode transitions using LayoutListener to update your UI accordingly:
CallSession? callSession = CallSession.getInstance();

callSession?.layoutListener = LayoutListener(
  onPictureInPictureLayoutEnabled: () {
    debugPrint("Entered PiP mode");
    // Hide custom overlays or controls
    hideCustomControls();
  },
  onPictureInPictureLayoutDisabled: () {
    debugPrint("Exited PiP mode");
    // Show custom overlays or controls
    showCustomControls();
  },
  onCallLayoutChanged: (LayoutType layoutType) {},
  onParticipantListVisible: () {},
  onParticipantListHidden: () {},
);
Remember to set the layoutListener to null in your widget’s dispose() method to prevent memory leaks.

Android Manifest Configuration

For Android, add PiP support to your Activity in AndroidManifest.xml:
<activity
    android:name=".MainActivity"
    android:supportsPictureInPicture="true"
    android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" />
AttributeDescription
supportsPictureInPictureEnables PiP support for the activity
configChangesPrevents activity restart during PiP transitions