cfug / dio

A powerful HTTP client for Dart and Flutter, which supports global settings, Interceptors, FormData, aborting and canceling a request, files uploading and downloading, requests timeout, custom adapters, etc.
https://dio.pub
MIT License
12.46k stars 1.51k forks source link

FormData and List of Int not working as expected. #2241

Open isalcedo opened 3 months ago

isalcedo commented 3 months ago

Package

dio

Version

5.4.3+1

Operating-System

Android, iOS

Adapter

Default Dio

Output of flutter doctor -v

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.2, on Arch Linux 6.9.3-arch1-1, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2023.3)
[✓] Connected device (3 available)
[✓] Network resources

Dart Version

Dart SDK version: 3.4.3 (stable)

Steps to Reproduce

  1. Declare: List<int> categories = [104, 105];
  2. Declare: Map<String, dynamic> jsonPayload = {'categories': categories};
  3. Print: print(FormData.fromMap(jsonPayload).fields);

Expected Result

[MapEntry(categories[0]: 104), MapEntry(categories[1]: 105)]

Actual Result

[MapEntry(categories: 104), MapEntry(categories: 105)]

coder-xb commented 3 months ago

I also encountered the same problem. This is my flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] Connected device (4 available)
[!] Network resources                   
    ✗ A network error occurred while checking "https://maven.google.com/": Operation timed out

! Doctor found issues in 1 category.

And my Dart SDK version also is 3.4.3(stable)

AlexV525 commented 3 months ago

Could you explain why you think the result should be the indexed version, maybe some specs or documents? Also it would be great if you could provide a working version of the library.