Not able to download Videos from Cloudflare bucket seamlessly, stucking at 0% and 100%

Hello Team,

We are facing download issue from our cloudflare bucket… in Flutter mobile app.
Sometimes it downloads perfectly but sometime does not, On 1-2% devices it is not working properly.
After asking developers they are saying it issue from cloudFlare side…

Below is sample code of Flutter for video download, It gets stuck on 0% and sometimes on 100%
attaching screenshots as well of real scenario, please let me know if need to post some other info as well.
Due to this issue our apps reputation is in danger, when we were using Digital Ocean there was no such issue.

Can anyone please guide any possible solution, is this Cloudflare issue or code issue?

Flutter Code

-------------- For Download Drive Videos -------------


static void downloadFromDrive({
    required String? url,
    required String? encryptionKey,
    required String? iv,
  }) async {
    print("***downloadFromDrive");

    DownloadFileModel? downloadFileModel = currentDownloadFile;

    downloadFileModel?.downloadProgress.value = '0';
    downloadFileModel?.status.value = DownloadStatus.started;

    final id = extractFileId(url ?? "");

    print(url);
    print(downloadFileModel?.name);

    final googleSignIn = GoogleSignIn(
      scopes: <String>[drive.DriveApi.driveScope, drive.DriveApi.driveMetadataScope],
    );

    try {
      GoogleSignInAccount? googleSignInAccount =
          await googleSignIn.signInSilently() ?? await googleSignIn.signIn().catchError((onError){   print(onError.toString());});

      if (googleSignInAccount == null) {
        throw ("Authentication failed");
      }
    } catch (e) {
      print(e.toString());
      downloadFileModel?.downloadProgress.value = '0';
      downloadFileModel?.status.value = DownloadStatus.readyToDownload;
      toast("Authentication failed");
      return;
    }

    var httpClient = (await googleSignIn.authenticatedClient());

    if (httpClient != null) {
      drive.DriveApi api = drive.DriveApi(httpClient);

      IOSink? sink;
      File? output;

      try {
        final metadata = await api.files.get(id!, downloadOptions: drive.DownloadOptions.metadata);

        final response = await api.files.get(id, downloadOptions: drive.DownloadOptions.fullMedia);

        var dirPath = await getDirectoryPath();

        output = File("$dirPath/${(metadata as drive.File).originalFilename ?? ''}");

        sink = output.openWrite();

        var tempProgress = 0;
        await for (List<int> data in (response as drive.Media).stream) {
          if (videoDownloadLoading.value) {
            sink.add(data);
            tempProgress = tempProgress + data.length;
            downloadFileModel?.downloadProgress.value = ((tempProgress * 100) /
                    ((response).length ?? double.parse(metadata.quotaBytesUsed ?? '1')))
                .toStringAsFixed(2);

            print(downloadFileModel?.downloadProgress.value);
          } else {
            await sink.close();
            File file = File(output.path);
            downloadFileModel?.downloadProgress.value = '0';
            downloadFileModel?.status.value = DownloadStatus.readyToDownload;
            await deleteFile(videoPath: file.path, isShowToast: false);
            downloadWaitingList
                .removeWhere((element) => element.fileId == downloadFileModel?.fileId);
            startNextDownload();
            return;
          }
        }

        await sink.close();

        await StorageService.setDownloadFilePath(
            path: output.path, fileId: downloadFileModel?.fileId);

        downloadFileModel?.downloadUrl = output.path;
        downloadFileModel?.downloadProgress.value = '0';
        downloadFileModel?.status.value = DownloadStatus.completed;

        print(output.path);

        if (!output.path.toLowerCase().contains(".pdf")) {
          await StorageService.setDownloadFiles(data: {
            'fileId': downloadFileModel?.fileId,
            'assignFileId': downloadFileModel?.assignFileId,
            "name": downloadFileModel?.name,
            "duration": downloadFileModel?.duration,
            "uploadedDate": downloadFileModel?.uploadedDate,
            "downloadUrl": downloadFileModel?.downloadUrl,
            // "iv": downloadFileModel?.iv,
            // "encKey": downloadFileModel?.encryptionKey,
          });
        }
        downloadWaitingList.removeWhere((element) => element.fileId == downloadFileModel?.fileId);

        startNextDownload();
      } catch (e) {
        print(e);

        if (e is drive.DetailedApiRequestError &&
            (e.errors.firstOrNull?.message?.isNotEmpty ?? false)) {
          toast(e.errors.firstOrNull?.message ?? "");
        }

        downloadFileModel?.downloadProgress.value = '0';
        downloadFileModel?.status.value = DownloadStatus.readyToDownload;
        await sink?.close();
        File file = File(output?.path ?? "");
        await deleteFile(videoPath: file.path, isShowToast: false);

        return;
      }
    }
  }

Error screenshots.

Anyone in the community who checked this, need urgent assistance plz.