dio
dio copied to clipboard
TypeErrorImpl (Unexpected null value.) Flutter Web
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
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 (
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