CodingAleCR / http_interceptor

A lightweight, simple plugin that allows you to intercept request and response objects and modify them if desired.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I use http_interceptor in flutter web?

mmadtop opened this issue · comments

Hello, I've succesfully used this library for a mobile app.
I'm trying to use it in a web app but it gives me error when I make a request with interceptor.

I would like to know if is not provided for the web version or if is another type of error.

Thank you in advance.

this is the stack:

onError Expected a value of type 'Exception', but got one of type 'UnsupportedError'
Error: Unhandled error Expected a value of type 'Exception', but got one of type 'UnsupportedError' occurred in Instance of 'AuthenticationBloc'.
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 212:49 throw
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 60:3 castError
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 442:10 cast
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart 411:9 as
packages/http_interceptor/http_client_with_interceptor.dart 222:23 _attemptRequest$
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1450:54 runUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 143:18 handleValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 696:44 handleValueCallbackC:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 725:32
_propagateToListeners
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 393:9 callback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 41:11 _microtaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 50:5 _startMicrotaskLoopC:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15

at Object.throw_ [as throw] (http://localhost:56368/dart_sdk.js:4334:11)
at http://localhost:56368/packages/bloc/src/cubit.dart.lib.js:105:21
at authentication_bloc.AuthenticationBloc.new.onError (http://localhost:56368/packages/bloc/src/cubit.dart.lib.js:106:26)
at authentication_bloc.AuthenticationBloc.new.onError (http://localhost:56368/packages/bloc/src/cubit.dart.lib.js:213:15)
at _RootZone.runBinaryGuarded (http://localhost:56368/dart_sdk.js:37400:11)
at sendError (http://localhost:56368/dart_sdk.js:31008:26)
at _BroadcastSubscription.new.[_sendError] (http://localhost:56368/dart_sdk.js:31025:11)
at _BroadcastSubscription.new.[_addError] (http://localhost:56368/dart_sdk.js:30948:27)
at http://localhost:56368/dart_sdk.js:31678:34
at _SyncBroadcastStreamController.new.[_forEachListener] (http://localhost:56368/dart_sdk.js:31524:13)
at _SyncBroadcastStreamController.new.[_sendError] (http://localhost:56368/dart_sdk.js:31676:31)
at _SyncBroadcastStreamController.new.[_addError] (http://localhost:56368/dart_sdk.js:31501:25)
at _RootZone.runBinaryGuarded (http://localhost:56368/dart_sdk.js:37400:11)
at sendError (http://localhost:56368/dart_sdk.js:31008:26)
at _ForwardingStreamSubscription.new.[_sendError] (http://localhost:56368/dart_sdk.js:31025:11)
at _ForwardingStreamSubscription.new.[_addError] (http://localhost:56368/dart_sdk.js:30948:27)
at _ForwardingStreamSubscription.new.[_addError] (http://localhost:56368/dart_sdk.js:35112:25)
at _MapStream.new.[_handleError] (http://localhost:56368/dart_sdk.js:35066:24)
at _ForwardingStreamSubscription.new.[_handleError] (http://localhost:56368/dart_sdk.js:35138:38)
at _RootZone.runBinaryGuarded (http://localhost:56368/dart_sdk.js:37400:11)
at sendError (http://localhost:56368/dart_sdk.js:31008:26)
at _ControllerSubscription.new.[_sendError] (http://localhost:56368/dart_sdk.js:31025:11)
at async._DelayedError.new.perform (http://localhost:56368/dart_sdk.js:34393:27)
at _StreamImplEvents.new.handleNext (http://localhost:56368/dart_sdk.js:34475:15)
at async._AsyncCallbackEntry.new.callback (http://localhost:56368/dart_sdk.js:34227:16)
at Object._microtaskLoop (http://localhost:56368/dart_sdk.js:37718:13)
at _startMicrotaskLoop (http://localhost:56368/dart_sdk.js:37724:13)
at http://localhost:56368/dart_sdk.js:33243:9

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.80. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Hi, short answer: currently no.

Long answer: I am working on it. Since Flutter Web is not stable yet it can change and it's not part of what I initially thought to implement. However, my plan for this is to add a separate branch that provides support for this, especially since this is really a simple plugin that should be allowed to be used in different platforms even while in beta.

Can you please keep this one open? Even though it's not stable yet, there are a lot of people using it already. And having this package work on web would be great.

Sure thing. Still on my to-do though

Sure thing. Still on my to-do though

what's the crux of the issue?
I set breakpoints and this is where the error is throwing:

void _initializeClient() {
var ioClient = new HttpClient()
..badCertificateCallback = badCertificateCallback
..findProxy = findProxy;
_client = IOClient(ioClient);
}

TBH, I didn't expect the plugin to be used much besides by myself, but I'm noticing an increase in the usage, so I'm moving this up in my priorities so that I can give proper maintenance to the plugin and provide usefulness out of it for the whole flutter community. So sorry it has taken this long 😔

As of 0.4.0 you should be able to use this plugin for flutter web without any issues. Cheers!