dio icon indicating copy to clipboard operation
dio copied to clipboard

TypeErrorImpl (Unexpected null value.) Flutter Web

Open muneebahmad0600 opened this issue 2 years ago • 1 comments

New Issue Checklist

  • [ ] I have searched for a similar issue in the project and found none

Issue Info

Info Value
Platform Name flutter / web
Platform Version Flutter 3.0.4 (Stable), Dart 2.17.5
Dio Version 4.0.6
Android Studio / Xcode Version e.g. Android Studio 2021.1
Repro rate e.g. all the time (100%)

Issue Description and Steps

I created a new project for flutter web. I am hitting the API and this is the response I am getting. TypeErrorImpl (Unexpected null value.). and Dio error stack trace is this.

"C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 963:28 get current packages/dio/src/dio_mixin.dart 473:35 fetch C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/dio/src/dio_mixin.dart 472:31 fetch packages/dio/src/dio_mixin.dart 468:12 request C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/dio/src/dio_mixin.dart 438:33 request packages/dio/src/dio_mixin.dart 91:12 post packages/cj_projects_web/src/services/auth.service.dart 13:33 logIn C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/cj_projects_web/src/services/auth.service.dart 11:29 logIn packages/cj_projects_web/src/providers/auth.provider.dart 20:35 logIn C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/cj_projects_web/src/providers/auth.provider.dart 19:22 logIn packages/cj_projects_web/src/screens/login_screen.dart 126:7 [_handleLogin] packages/flutter/src/material/ink_well.dart 1005:21 [_handleTap] packages/flutter/src/material/ink_well.dart 775:5 [_simulateTap] packages/flutter/src/widgets/actions.dart 534:39 invoke packages/flutter/src/widgets/actions.dart 1500:21 invoke packages/flutter/src/widgets/actions.dart 573:20 invokeAction packages/flutter/src/widgets/shortcuts.dart 755:36 handleKeypress packages/flutter/src/widgets/shortcuts.dart 956:20 [_handleOnKey] packages/flutter/src/widgets/focus_manager.dart 1687:25 [_handleKeyMessage] packages/flutter/src/services/hardware_keyboard.dart 828:16 [_dispatchKeyMessage] packages/flutter/src/services/hardware_keyboard.dart 875:73 handleRawKeyMessage C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/flutter/src/services/hardware_keyboard.dart 854:51 handleRawKeyMessage packages/flutter/src/services/platform_channel.dart 77:49 C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/flutter/src/services/platform_channel.dart 76:58 packages/flutter/src/services/binding.dart 380:35 C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/flutter/src/services/binding.dart 377:98 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/platform_dispatcher.dart 1121:13 invoke2 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/ui/channel_buffers.dart 25:12 invoke C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/ui/channel_buffers.dart 65:7 push C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/ui/channel_buffers.dart 130:16 push C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/platform_dispatcher.dart 305:25 invokeOnPlatformMessage C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/keyboard.dart 130:39 [_handleHtmlEvent] C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/keyboard.dart 32:7 "

I have already tried: lowering the version to 4.0.4 removing time out from Dio initialization. disabling firewall ( just because I saw this somewhere. ) Migrated from flutter stable to master and back again. ran flutter pub clean a bench of times.

Kindly help!!! I'll paste the flutter doctor as well just in case.

[√] Flutter (Channel stable, 3.0.4, on Microsoft Windows [Version 10.0.22000.739], locale en-US) • Flutter version 3.0.4 at D:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 85684f9300 (8 days ago), 2022-06-30 13:22:47 -0700 • Engine revision 6ba2af10bb • Dart version 2.17.5 • DevTools version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) • Android SDK at C:\Users\hp\AppData\Local\Android\sdk • Platform android-32, build-tools 32.1.0-rc1 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop for Windows (Visual Studio Community 2022 17.0.6) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.0.32126.317 X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components: MSVC v142 - VS 2019 C++ x64/x86 build tools - If there are multiple build tool versions available, install the latest C++ CMake tools for Windows Windows 10 SDK

[√] Android Studio (version 2021.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)

[√] VS Code (version 1.68.1) • VS Code at C:\Users\hp\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.44.0

[√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.739] • Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.114 • Edge (web) • edge • web-javascript • Microsoft Edge 103.0.1264.44

[√] HTTP Host Availability • All required HTTP hosts are available

! Doctor found issues in 1 category.

Also.. this is my debug console at the time.. I can't figure out what is wrong with this?

Error: Expected a value of type 'String', but got one of type 'Null' at Object.throw_ [as throw] (http://localhost:65467/dart_sdk.js:5080:11) at Object.castError (http://localhost:65467/dart_sdk.js:5039:15) at Object.cast [as as] (http://localhost:65467/dart_sdk.js:5356:17) at String.as (http://localhost:65467/dart_sdk.js:46240:19) at auth$46service.AuthService.new.logIn (http://localhost:65467/packages/cj_projects_web/src/services/auth.service.dart.lib.js:36:47) at logIn.throw () at http://localhost:65467/dart_sdk.js:40646:38 at _RootZone.runBinary (http://localhost:65467/dart_sdk.js:40515:59) at _FutureListener.thenAwait.handleError (http://localhost:65467/dart_sdk.js:35449:33) at handleError (http://localhost:65467/dart_sdk.js:36015:51) at _Future._propagateToListeners (http://localhost:65467/dart_sdk.js:36041:17) at [_completeError] (http://localhost:65467/dart_sdk.js:35878:23) at [_completeError] (http://localhost:65467/dart_sdk.js:35358:36) at _SyncCompleter.new.completeError (http://localhost:65467/dart_sdk.js:35282:29) at onError (http://localhost:65467/dart_sdk.js:35122:49) at _RootZone.runBinary (http://localhost:65467/dart_sdk.js:40515:59) at _FutureListener.then.handleError (http://localhost:65467/dart_sdk.js:35449:33) at handleError (http://localhost:65467/dart_sdk.js:36015:51) at _Future._propagateToListeners (http://localhost:65467/dart_sdk.js:36041:17) at [_completeError] (http://localhost:65467/dart_sdk.js:35878:23) at Object._completeWithErrorCallback (http://localhost:65467/dart_sdk.js:40748:27) at http://localhost:65467/dart_sdk.js:34910:21 at internalCallback (http://localhost:65467/dart_sdk.js:26685:11)

muneebahmad0600 avatar Jul 08 '22 19:07 muneebahmad0600

i have same problem, try this on Mac: close all google chrome open /Applications/Google\ Chrome.app --args --user-data-dir="/var/tmp/Chrome dev session" --disable-web-security

run app, copy paste ulr from flutter run browser to first chrome browser open with flag

nifhanif avatar Aug 18 '22 01:08 nifhanif