Questions tagged [dio]

Dio is a powerful HTTP client for Dart, which supports interceptors, global configuration, form data, request cancellation, file downloading, timeout, etc.

Dio is a powerful HTTP client for Dart, which supports interceptors, global configuration, form data, request cancellation, file downloading, timeout, etc.

References

Dio Dart package.

664 questions
40
votes
7 answers

Unable to add header for post method in dio in Flutter

I'm using dio: ^3.0.4. Any one please help me to find the solution for adding header. here my code: FormData formData = new FormData.fromMap({"files": await MultipartFile.fromFile(filePath.path, filename: 'photo') }); Response…
Vexal
  • 695
  • 2
  • 9
  • 16
40
votes
8 answers

Flutter Dio : How to Upload Image?

I'm trying on Postman. And it works I want upload some image to rest-api using Package DIO Package , I'm new for this package (i'm use this package just for CRUD operation) and i'm got problem when upload image operation. i'm already reading…
Zeffry Reynando
  • 3,445
  • 12
  • 49
  • 89
20
votes
6 answers

Flutter: How to increase onSendProgress calls for a fluid progress bar animation while uploading files?

I have the following code to upload a file. var client = new dio.Dio(); await client.put( url, data: formData, options: dio.Options( headers: headers, ), onSendProgress: (int sent, int total) { final progress = sent / total; …
Tom Aalbers
  • 4,574
  • 5
  • 29
  • 51
16
votes
4 answers

SocketException: Failed host lookup: ‘...com’ (OS Error: nodename nor servname provided, or not known, errno = 8)

We are in a situation where the production app is facing the following socket exception and not able to perform any other network operation after this.  DioError [DioErrorType.DEFAULT]: SocketException: Failed host lookup: ‘xyz.abc.com’ (OS Error:…
Tapas Pal
  • 7,073
  • 8
  • 39
  • 86
15
votes
4 answers

How to handle timeout error with Dio in Flutter?

I'm using Dio to handle APIs functions. Here's my code: Future> getItems() async { try { Response response = await dio.get("$_apiUrl$_itemEndPoint", options: Options(headers: { "Accept":…
Abdurrahman Anas
  • 665
  • 2
  • 9
  • 21
12
votes
4 answers

The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type

I'm using new dart version >=2.12.0 <3.0.0 with null safety enabled. I have added my code for reference. MatchesService import 'package:cric_app/AppUrls.dart'; import 'package:cric_app/features/home/match_model.dart'; import…
Pranav Kumar K
  • 187
  • 1
  • 1
  • 10
11
votes
4 answers

Flutter - Insecure socket connections are disallowed by platform: 10.0.2.2

Since today whenever I try to login my application I get the following error thrown by the Dio package: SocketException: Insecure socket connections are disallowed by platform: 10.0.2.2 I use the following settings to connect: static BaseOptions…
user11939761
10
votes
1 answer

How to send FormData with Dio?

Hello I am sending a FormData using Dio but when this is sent, the website returns an error var formData = FormData.fromMap({ "ctl00\$ScriptManager1": "ctl00\$UpdatePanel1", "__EVENTTARGET" :"ctl00\$cphPage\$productsControl", …
10
votes
2 answers

Use Flutter to send a http Post-Request (containing an image) to a Flask API

I've trained a CNN on the CIFAR10 dataset (placeholder, will be replaced with a different model later) and integrated the model into a flask API. The API is hosted on Heroku, and I would now like to use Flutter / Dart to take pictures on my phone,…
Ultralite
  • 174
  • 1
  • 2
  • 11
9
votes
5 answers

Dio interceptor for refreshing access token

I am trying to implement a access token refresh with a Dio interceptor. I have looked at examples I could find, none of which seem to work. Here is my attempt: class AuthInterceptor extends QueuedInterceptor { final Dio dio; final AuthService…
Neigaard
  • 3,726
  • 9
  • 49
  • 85
9
votes
1 answer

How to send multipart file with Flutter

I would like to send a picture as a multipart file to the server. First I tried to use http.post : var response = await http.post( Uri.parse('url.php'), headers:{ "Content-Type":"multipart/form-data" } , body: { "fichier":…
JS1
  • 631
  • 2
  • 7
  • 23
9
votes
1 answer

Flutter DIO library XMLHttpRequest error Web

I have working with Flutter DIO Library. Its working fine on my Android App but giving error on Web. Error: DioError [DioErrorType.response]: XMLHttpRequest error. If I tried same url with http its working fine for Web. My Dio Library code Dio dio =…
Honey Last
  • 255
  • 1
  • 3
  • 15
9
votes
2 answers

Flutter Dart Dio Get Request is so slow

I am hosting a space in digital ocean - it is basically Amazon S3 equalivant of digital ocean. My problem with dio is, I am making a get request with dio to a file of 10MB size. The request takes around 9 seconds on my phone but 3 seconds in my…
cs guy
  • 926
  • 2
  • 13
  • 33
9
votes
7 answers

Flutter DIO: upload image using binary body with Dio package

With thwe http package I can send an image to a server by putting te binary data in the body of a post call like in the snippet of this code: var response = await http.post('My_url', body: File(path).readAsBytesSync(), headers: { …
Jaeger
  • 331
  • 1
  • 2
  • 11
9
votes
2 answers

Flutter : Can't get array json using dio to list of object

I tried to load array json (array with no key) and fetch into list of object, here is my sample code : My ApiCliet : Future> fetchOnboarding() async { try { Response response = await dio.get("api/OnboardingItem"); …
Bali Codes
  • 581
  • 1
  • 5
  • 8
1
2 3
44 45