Flutter Uploading a video through DIO package on Isolate
Asked Answered
U

0

6

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.

Unruh answered 22/10, 2020 at 12:6 Comment(2)
Hi, I'm also facing the same issue. Did you find any solutions?Palpitation
I have the same issue. Due to that my Flutter web app is not working properly. See discord.com/channels/420324994703163402/530797119389564939/…Jerad

© 2022 - 2024 — McMap. All rights reserved.