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

BrowserHttpClientAdapter got error #2393

Open
byte-art opened this issue Mar 31, 2025 · 1 comment
Open

BrowserHttpClientAdapter got error #2393

byte-art opened this issue Mar 31, 2025 · 1 comment
Labels
h: need triage This issue needs to be categorized s: bug Something isn't working

Comments

@byte-art
Copy link

byte-art commented Mar 31, 2025

Package

web_adapter

Version

5.8.0+1

Operating-System

Web, Android

Adapter

Default Dio

Output of flutter doctor -v

[!] Flutter (Channel stable, 3.24.4, on Microsoft Windows [版本 10.0.22621.1702], locale zh-CN)
    ! Warning: `flutter` on your path resolves to D:\FlutterSdk\flutter_windows_3.22.2-stable\flutter\bin\flutter, which
      is not inside your current Flutter SDK checkout at D:\FlutterSdk\flutter_windows_3.24.4-stable. Consider adding
      D:\FlutterSdk\flutter_windows_3.24.4-stable\bin to the front of your path.
    ! Warning: `dart` on your path resolves to D:\FlutterSdk\flutter_windows_3.22.2-stable\flutter\bin\dart, which is
      not inside your current Flutter SDK checkout at D:\FlutterSdk\flutter_windows_3.24.4-stable. Consider adding
      D:\FlutterSdk\flutter_windows_3.24.4-stable\bin to the front of your path.
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/windows-android-setup for more details.
[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2020.3)
[√] Android Studio (version 2024.1)
[√] VS Code (version 1.95.3)
[√] Connected device (4 available)
[!] Network resources
    X A network error occurred while checking "https://github.com/": 信号灯超时时间已到

Dart Version

3.5.4

Steps to Reproduce

when I tried to used BrowserHttpClientAdapter on web project and compatible App,try to import package:dio/browser.dart and run again,show some error.

Codes:

import 'dart:developer';
import 'dart:io';

import 'package:dio/browser.dart';
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_common/http/http_config.dart';

class AppDio with DioMixin implements Dio {
late HttpConfig dioConfig;

AppDio({BaseOptions? options, HttpConfig? dioConfig}) {
this.options = options!;
this.dioConfig = dioConfig!;
if (dioConfig.interceptors?.isNotEmpty ?? false) {
interceptors.addAll(dioConfig.interceptors!);
}
if (kDebugMode) {
interceptors.add(
LogInterceptor(
responseBody: true,
error: true,
requestHeader: true,
responseHeader: true,
request: true,
requestBody: true,
logPrint: (content) {
log(content.toString());
},
),
);
}
if (kIsWeb) {
httpClientAdapter = BrowserHttpClientAdapter(withCredentials: true);
} else {
httpClientAdapter = IOHttpClientAdapter();
(httpClientAdapter as IOHttpClientAdapter).createHttpClient = () {
final client = HttpClient();
client.badCertificateCallback = (cert, host, port) => true;
return client;
};
}
}
}

Expected Result

normal operation

Actual Result

When I try to Run, Console show error:

CHE/hosted/pub.flutter-io.cn/web-1.1.1/lib/src/dom/svg.dart:307:63: Error: Type 'JSObject' not found.
extension type SVGBoundingBoxOptions._(JSObject ) implements JSObject {
^^^^^^^^
/D:/PUB_CACHE/hosted/pub.flutter-io.cn/web-1.1.1/lib/src/dom/svg.dart:332:37: Error: Type 'JSObject' not found.
extension type SVGGraphicsElement.
(JSObject )
^^^^^^^^
/D:/PUB_CACHE/hosted/pub.flutter-io.cn/web-1.1.1/lib/src/dom/svg.dart:333:28: Error: Type 'JSObject' not found.
implements SVGElement, JSObject {
^^^^^^^^
/D:/PUB_CACHE/hosted/pub.flutter-io.cn/web-1.1.1/lib/src/dom/svg.dart:366:37: Error: Type 'JSObject' not found.
extension type SVGGeometryElement.
(JSObject _)

When I remove 'import 'package:dio/browser.dart';', it can run.

@byte-art byte-art added h: need triage This issue needs to be categorized s: bug Something isn't working labels Mar 31, 2025
@AlexV525
Copy link
Member

You should probably run the pub upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
h: need triage This issue needs to be categorized s: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants