Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error (Xcode): ../../.pub-cache/hosted/pub.dev/dio_web_adapter-2.0.0/lib/src/adapter.dart:3:8: Error: Dart library 'dart:js_interop' is not available on this platform. #2372

Closed
isaanyoha opened this issue Jan 30, 2025 · 3 comments
Labels
i: wontfix This will not be worked on

Comments

@isaanyoha
Copy link

isaanyoha commented Jan 30, 2025

Package

dio

Version

5.8.0+1

Operating-System

iOS

Adapter

Default Dio

Output of flutter doctor -v

No response

Dart Version

3.6.1

Steps to Reproduce

Please why are my getting this error [see the error below] when I did not explicitly called 'dio_web_adapter' package in my pubspec.yml? I am only using package dio (upgrade from dio: ^5.3.2 to dio: ^5.8.0+1, but issue still persists)

I am trying to build for iphone is yet I get that the error above:

I have tried:
rm -rf .dart_tool
rm -rf .flutter-plugins
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/.pub-cache

---------MY pubspec.yml-------
sdk: ">=3.0.0 <4.0.0"

dependencies:
dio: ^5.8.0+1

Expected Result

no error and work well.

Actual Result

Launching lib/main.dart on iPhone SE (3rd generation) in debug mode...
Running pod install...
Running Xcode build...
Xcode build done. 260.8s
Failed to build iOS app
Error (Xcode): ../../.pub-cache/hosted/pub.dev/dio_web_adapter-2.0.0/lib/src/adapter.dart:3:8: Error: Dart library 'dart:js_interop' is not available on this platform.

Could not build the application for the simulator.
Error launching application on iPhone SE (3rd generation).

@isaanyoha isaanyoha added h: need triage This issue needs to be categorized s: bug Something isn't working labels Jan 30, 2025
@AlexV525
Copy link
Member

Could you run flutter pub upgrade? If the issue persist, please provide a minimal reproducible example and the full log of flutter run -v.

@AlexV525 AlexV525 added the h: need more info Further information is requested label Jan 31, 2025
@suojae
Copy link
Contributor

suojae commented Jan 31, 2025

Image

It seems that the error occurs because dio_web_adapter is being loaded on iOS, which tries to import dart:js_interop, a library that is only available in web environments. Since dio_web_adapter is designed for web use, should we also add a print statement inside HttpClientAdapter() to log whether dart:js_interop is being used?

@AlexV525
Copy link
Member

@suojae : Thanks for the repro.

No, I don't think we should handle cases like this.

Closing as won't fix.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2025
@AlexV525 AlexV525 added i: wontfix This will not be worked on and removed h: need more info Further information is requested h: need triage This issue needs to be categorized s: bug Something isn't working labels Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i: wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants