MediaProjection Creator

pub package

A flutter plugin of the creator used to create MediaProjection instance (with requesting permission) for Android

Note: Only support Android


If you need to implement screen capture on iOS, I have also developed two helpful plugins:

  1. ReplayKit Launcher: A flutter plugin of the launcher used to open RPSystemBroadcastPickerView for iOS

  2. Shared preferences with App Group: Shared preference supporting iOS App Group capability (using -[NSUserDefaults initWithSuiteName:])


To use this plugin, add media_projection_creator as a dependency in your pubspec.yaml file.


  • Flutter
int errorCode = await MediaProjectionCreator.createMediaProjection();
if (errorCode == MediaProjectionCreator.ERROR_CODE_SUCCEED) {
    print('createMediaProjection succeed');
  • Android
public class MainActivity extends FlutterActivity {

    private static MediaProjection mediaProjection;

    protected void onCreate(@Nullable Bundle savedInstanceState) {

        /// Example: developers should call this method to set callback,
        /// when dart call `createMediaProjection`, it would be return a MediaProjection through this callback

        /// Customize the media projection foreground notification style (available since Android Q)
        /// If not set, it will be the system default style
        RequestMediaProjectionPermissionManager.getInstance().setForegroundServiceNotificationStyle(R.mipmap.ic_launcher, "Screen is being captured");

    private final MediaProjectionCreatorCallback mediaProjectionCreatorCallback = new MediaProjectionCreatorCallback() {

        public void onMediaProjectionCreated(MediaProjection projection, int errorCode) {
            if (errorCode == RequestMediaProjectionPermissionManager.ERROR_CODE_SUCCEED) {
                Log.i("MEDIA_PROJECTION_CREATOR", "Create media projection succeeded!");
                mediaProjection = projection;
            } else if (errorCode == RequestMediaProjectionPermissionManager.ERROR_CODE_FAILED_USER_CANCELED) {
                Log.e("MEDIA_PROJECTION_CREATOR", "Create media projection failed because can not get permission");
            } else if (errorCode == RequestMediaProjectionPermissionManager.ERROR_CODE_FAILED_SYSTEM_VERSION_TOO_LOW) {
                Log.e("MEDIA_PROJECTION_CREATOR", "Create media projection failed because system api level is lower than 21");

Please see the example app of this plugin for a full example.

Another practical demo

This demo implements screen live broadcast on iOS/Android by using the ZEGO Express Audio and Video Flutter SDK


Everyone is welcome to contribute code via pull requests, to help people asking for help, to add to our documentation, or to help out in any other way.