Flutter Uploading a video through DIO package on Isolate

1.3k Views Asked by At

I'm trying to upload a video on my AWS S3 server using dio package.

What is happening:

video's are uploading successfully but the api call blocks the UI thread and it will really slow down the app during upload. All other api calls through dio are not affecting UI.

Here is my code:

dio.FormData formData = dio.FormData.fromMap({
        "video": multiplartFiles,
        "video_id": videoId,
      });

dio.Dio dioInstance = new dio.Dio(); 
dioInstance.options.headers = headers;
final response = await dioInstance.post(uploadVideoEndPoint, data: formData, onSendProgress: (val1, val2) {
print('$val1 / $val2');
}).catchError((error) { 
return Response(success: false, error: "Unable to upload video. Please check your network connection and try again"); 
});

Things I do:

Move all my uploading code to Isolate it hit api but it didn't get any response and it did not show any error on server side.

Did dio works on isolate?

Expected Result:

While uploading video UI should not get slow.

0

There are 0 best solutions below