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

Type Casting Error: '_Map<String, dynamic>' is not a Subtype of 'T?' #2231

Closed
AmeerAmjed opened this issue Jun 3, 2024 · 1 comment
Closed

Comments

@AmeerAmjed
Copy link

Package

dio

Version

5.4.3+1

Operating-System

Android, iOS

Adapter

Default Dio

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.22.1, on macOS 14.4.1 23E224 darwin-arm64, locale en-IQ)
    • Flutter version 3.22.1 on channel stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (12 days ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/ameeramjed/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio Preview.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    ✗ Unable to get list of installed Simulator runtimes.
    • CocoaPods version 1.14.3

[!] Android Studio (version unknown)
    • Android Studio at /Applications/Android Studio Preview.app/Contents
    • 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
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] IntelliJ IDEA Community Edition (version 2024.1.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • 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

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (2 available)


[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Dart Version

3.4.1

Steps to Reproduce

I need to convert the data response to a specific type T .

client.get<TodosResponse>(
        '/todos',
        queryParameters: {
          "skip": skip,
          "limit": limit,
        },
      ),

but show this error
Error: type '_Map<String, dynamic>' is not a subtype of type 'TodosResponse?' in type cast.
I do not need to use any function or more steps because I use base class and just pass request to use the same error Handel I need to cast without any logic using passing T.
How can handle that?
Thank you for helping me.

Expected Result

Error: type '_Map<String, dynamic>' is not a subtype of type 'TodosResponse?' in type cast.

Actual Result

Return Object of TodosResponse.

@AmeerAmjed AmeerAmjed added h: need triage This issue needs to be categorized s: bug Something isn't working labels Jun 3, 2024
@AlexV525
Copy link
Member

AlexV525 commented Jun 4, 2024

There should be tutorials about converting the response into your abstracted classes. Please search any forums for help, we use issues to track bugs/features.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 4, 2024
@AlexV525 AlexV525 added i: stackoverflow and removed h: need triage This issue needs to be categorized s: bug Something isn't working labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants