Repository navigation
Description
Package
native_dio_adapter
Version
1.8.0
Operating-System
iOS, Android
Adapter
NativeAdapter
Output of flutter doctor -v
[✓] Flutter (Channel stable, 3.47.8, on macOS 26.6.2 25G83 darwin-arm64, locale en-US)
• Flutter version 3.47.8 on channel stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 737ba8f885, 2026-10-22 21:37:31 -0700
• Engine revision cf636b1dfb
• Dart version 3.13.7
• DevTools version 2.60.0
[✓] Android toolchain - develop for Android devices (Android SDK version 37.0.0)
• Platform android-37.0, build-tools 37.0.0
• Java version OpenJDK Runtime Environment (build 21.0.10+-117844308-b1163.108)
[✓] Xcode - develop for iOS and macOS (Xcode 27.1)
• Build 27A9275
• CocoaPods version 1.16.2
[✓] Connected device
• iPhone (mobile) • ios • iOS 27.0.1 24A446
• macOS (desktop) • macos • darwin-arm64 • macOS 26.6.2 25G83 darwin-arm64Dart Version
3.13.7
Steps to Reproduce
With NativeAdapter, request a URL that redirects and read realUri:
final dio = Dio()..httpClientAdapter = NativeAdapter();
final response = await dio.get<String>('https://httpbin.org/redirect-to?url=https://example.com/');
print(response.realUri);
print(response.redirects);Expected Result
response.realUri is the final URL (https://example.com/) and response.redirects is not empty, the same as with the default IOHttpClientAdapter.
Actual Result
response.realUri is still the requested URL and response.redirects is empty.
cupertino_http and cronet_http follow redirects natively and return a response that implements BaseResponseWithUrl, whose url is the final URL. ConversionLayerAdapter builds the ResponseBody without redirects, so dio falls back to requestOptions.uri. Anything that relies on realUri (logging where a request actually went, noticing an unexpected redirect, resolving relative links in the body) gets the wrong value, and the same code behaves differently depending on the adapter.
Proposed fix: when the response is a BaseResponseWithUrl and its url differs from the request URL, add one RedirectRecord for it. The native clients don't report the hops in between or their status codes, so that record can only describe the final destination. Draft PR with tests: #2630.
Activity