Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.7 kB
4
Indexable
Never
 resignFileUpload() async {
    if (Platform.isAndroid) {
      AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
      int? androidVersion = androidInfo.version.sdkInt;
      if (androidVersion! <= 32) {
        await Permission.storage.request();
        var status = Permission.storage.status;
        if (await status.isGranted) {
          FilePickerResult? result = await FilePicker.platform.pickFiles(
            type: FileType.custom,
            allowedExtensions: ['pdf', 'png', 'jpg', 'jpeg'],
          );

          if (result != null) {
            selectedFileResign = File(result.paths.first!);
            fileData = result.files.first;
            fileResign = result.files.first;
            filePickResign = true;
            fileExtensionResign = fileResign!.extension.toString();
          }

          update();
        } else {
          Get.snackbar(AppString.warning, AppString.permissionStorage,
              backgroundColor: AppColors.primaryBlack,
              colorText: AppColors.primaryWhite,
              duration: const Duration(seconds: 2),
              snackPosition: SnackPosition.TOP);
        }
      } else {
        if (allAccepted) {
          FilePickerResult? result = await FilePicker.platform.pickFiles(
            type: FileType.custom,
            allowedExtensions: ['pdf', 'png', 'jpg', 'jpeg'],
          );

          if (result != null) {
            selectedFileResign = File(result.paths.first!);
            fileData = result.files.first;
            fileResign = result.files.first;
            filePickResign = true;
            fileExtensionResign = fileResign!.extension.toString();
          }

          update();
        }
      }
    } else {
      var status = Permission.storage.status;
      if (await status.isGranted) {
        // You can request multiple permissions at once.

        FilePickerResult? result = await FilePicker.platform.pickFiles(
          type: FileType.custom,
          allowedExtensions: ['pdf', 'png', 'jpg', 'jpeg'],
        );

        if (result != null) {
          selectedFileResign = File(result.paths.first!);
          fileData = result.files.first;
          fileResign = result.files.first;
          filePickResign = true;
          fileExtensionResign = fileResign!.extension.toString();
        }

        update();
      } else {
        Get.snackbar(AppString.warning, AppString.permissionStorage,
            backgroundColor: AppColors.primaryBlack,
            colorText: AppColors.primaryWhite,
            duration: const Duration(seconds: 2),
            snackPosition: SnackPosition.TOP);
      }
    }
    update();
  }









////////





Leave a Comment