Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform exception: PlatformException(already_active, File picker is already active, null, null) in work profile #1362

Closed
Cypher103360 opened this issue Sep 4, 2023 · 2 comments
Labels

Comments

@Cypher103360
Copy link

Cypher103360 commented Sep 4, 2023

Future<void> selectFile() async {
      FilePickerResult? result = await FilePicker.platform.pickFiles(
        type: FileType.custom,
        allowedExtensions: ['pdf', 'jpg', 'jpeg', 'png'],
        allowMultiple: false,
      ) ??
          const FilePickerResult(<PlatformFile>[]);

      if (result.files.isNotEmpty) {
        File selected = File(result.files.single.path!);
        String fileExtension = selected.path
            .split('.')
            .last
            .toLowerCase();

        if (fileExtension == 'pdf' ||
            fileExtension == 'jpg' ||
            fileExtension == 'jpeg' ||
            fileExtension == 'png') {
          int fileSize = selected.lengthSync();
          if (fileSize <= 1024 * 1024) {
            if (widget.dialogType == "postLeave") {
              _allLeaveViewModel.selectedFile.value = selected;
              print("SelectedFile1: ${_allLeaveViewModel.selectedFile.value}");
            } else {
              _myLeavesViewModel.selectedFile.value = selected;
              print("SelectedFile2: ${_myLeavesViewModel.selectedFile.value}");
            }
            setState(() {
              selectedFile = selected;
            });
          } else {
            showFileSizeExceededDialog();
          }
        } else {
          showInvalidFileTypeDialog();
        }
      }
  }

I have two profiles on my phone: 1. personal profile and 2. work profile. The above-mentioned code works well in the personal profile, but when I try to run the same code in the work profile, it throws this error:

I/flutter (26152): [MethodChannelFilePicker] Platform exception: PlatformException(already_active, File picker is already active, null, null)
E/flutter (26152): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(already_active, File picker is already active, null, null)
E/flutter (26152): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
E/flutter (26152): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
E/flutter (26152): <asynchronous suspension>
E/flutter (26152): #2      MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:496:35)
E/flutter (26152): <asynchronous suspension>
E/flutter (26152): #3      FilePickerIO._getPath (package:file_picker/src/file_picker_io.dart:92:33)
E/flutter (26152): <asynchronous suspension>
E/flutter (26152): #4      _UploadFileWidgetState.selectFile (package:feeta/views/other_widgets/upload_file_widget.dart:47:34)
E/flutter (26152): <asynchronous suspension>
E/flutter (26152): 
F/crash_dump64(11881): crash_dump.cpp:494] failed to attach to thread 780: Permission denied
F/crash_dump64(12006): crash_dump.cpp:494] failed to attach to thread 809: Permission denied

Devices in which this issue is occurring:

  • Redmi Note 8 - OS 12.5.2 - Android 11
  • Redmi Note 8 pro - OS 12.5.10 - Android 11
  • Redmi Note 9 - OS 12.5.6 - Android 11
  • OnePlus 8t - OS 13.1 - Android 13

Can anyone please tell me why I am getting this error in my work profile especially, and why I am unable to pick files from the storage?

@Cypher103360 Cypher103360 changed the title Platform exception: PlatformException(already_active, File picker is already active, null, null) in work profile``` Platform exception: PlatformException(already_active, File picker is already active, null, null) in work profile Sep 4, 2023
@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Sep 12, 2023
@github-actions
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant