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.5k stars 1.51k forks source link

Is it a problem that the Dio library cannot be viewed using the Networks view in Flutter's devtools to view the requests made by Dio? #2326

Open xhc-code opened 2 days ago

xhc-code commented 2 days ago

Package

dio

Version

dio: ^5.4.3+1

Operating-System

Android

Adapter

Default Dio

Output of flutter doctor -v

• Flutter version 3.24.3 on channel stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (9 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Platform android-35, build-tools 35.0.0
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
    • All Android licenses accepted.

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.5)
    • Visual Studio Community 2022 version 17.11.35327.3
    • Windows 10 SDK version 10.0.22621.0

[✓] Network resources
    • All expected network resources are available.

Dart Version

3.5.3

Steps to Reproduce

image image

The HTTP interface requests sent cannot be displayed and are all displayed as sockets.

Expected Result

Actual display of the request address and parameter information of the interface

Actual Result

Cannot display the true information of the request sent.


In the issue of devtool, many people have also encountered such problems, and the final conclusion is that Dio may not have used the basic request library provided by Flutter, which resulted in devtool being unable to capture requests sent through Dio. https://github.com/flutter/devtools/issues/8518

AlexV525 commented 2 days ago

Are you using native_dio_adapter?

xhc-code commented 2 days ago

Are you using native_dio_adapter?

indeterminacy,But the httpClientAdapter parameter is not configured

AlexV525 commented 2 days ago

Could you write a minimal reproducible example?

xhc-code commented 1 day ago

好的。

xhc-code commented 1 day ago

https://github.com/xhc-code/my_flutter_network_problem.git image

The code here includes both HTTP and sockets when using Dio to request linked data. Moreover, the number of socket and get requests is not equal.

The code in the project has not been fully reproduced (only socket requests appear), and there may be additional configurations for the Dio in the project, but I need to check again.