Skip to content

type 'Future<dynamic>' is not a subtype of type 'Future<Response<dynamic>>' #1

Closed

Description

@arden
[VERBOSE-2:dart_error.cc(16)] Unhandled exception:
type 'Future<dynamic>' is not a subtype of type 'Future<Response<dynamic>>' where
  Future is from dart:async
  Future is from dart:async
  Response is from package:dio/src/Response.dart

#0      Dio._onError (package:dio/src/Dio.dart:526:12)
#1      Dio._makeRequest.<anonymous closure> (package:dio/src/Dio.dart:420:28)
#2      Dio._checkIfNeedEnqueue (package:dio/src/Dio.dart:554:22)
#3      Dio._makeRequest (package:dio/src/Dio.dart:416:35)
<asynchronous suspension>
#4      Dio._request.<anonymous closure> (package:dio/src/Dio.dart:316:16)
#5      Dio._checkIfNeedEnqueue (package:dio/src/Dio.dart:554:22)
#6      Dio._request (package:dio/src/Dio.dart:287:31)
<asynchronous suspension>
#7      Dio.request (package:dio/src/Dio.dart:270:12)
<asynchronous suspension>
#8      Dio.get (package:dio/src/Dio.dart:62:12)
#9      UserApi.getUser (package:saytoken_flutter/api/user_api.dart:12:31)
<asynchronous suspension>
#10     _LoginPageState.login (package:<…>
[VERBOSE-2:dart_error.cc(16)] Unhandled exception:
DioError [DioErrorType.DEFAULT]: type 'Future<dynamic>' is not a subtype of type 'Future<Response<dynamic>>' where
  Future is from dart:async
  Future is from dart:async
  Response is from package:dio/src/Response.dart
#0      Dio.resolve (package:dio/src/Dio.dart:112:21)
#1      Dio._onSuccess (package:dio/src/Dio.dart:509:18)
#2      Dio._makeRequest.<anonymous closure> (package:dio/src/Dio.dart:398:57)
#3      Dio._checkIfNeedEnqueue (package:dio/src/Dio.dart:554:22)
#4      Dio._makeRequest (package:dio/src/Dio.dart:393:33)
<asynchronous suspension>
#5      Dio._request.<anonymous closure> (package:dio/src/Dio.dart:316:16)
#6      Dio._checkIfNeedEnqueue (package:dio/src/Dio.dart:554:22)
#7      Dio._request (package:dio/src/Dio.dart:287:31)
<asynchronous suspension>
#8      Dio.request (package:dio/src/Dio.dart:270:12)
<asynchronous suspension>
#9      Dio.get (package:dio/src/Dio.dart:62:12)
#10     UserApi.getUser (package:saytoken_flutter/ap<…>

Activity

  1. wendux commented on Apr 27, 2018

    @wendux
    Contributor

    已修复,请升级到0.0.9重试.

  2. Yaxian commented on Jul 18, 2018

    @Yaxian

    Hi, @wendux
    I meet this issue with version 0.1.3, when I call dio.download method.
    env:

    • dio: ^0.1.3
    • Flutter: Channel beta, v0.5.1

    but version 0.0.14 works fine.

  3. wendux commented on Jul 19, 2018

    @wendux
    Contributor

    @Yaxian fixed, please update to 0.1.4 and try again.

  4. zhouxianjun commented on Jul 8, 2019

    @zhouxianjun

    在2.1.7版本中,使用lock并且使用泛型response则会导致类型不匹配错误,初步原因:
    image
    在980行enqueue这个函数并没有声明泛型类型。
    image

  5. zhouxianjun commented on Jul 8, 2019

    @zhouxianjun

    @wendux 请查看下

  6. lucien-theron commented on Jul 15, 2019

    @lucien-theron

    I get this exception by simply returning: .catchError((error, stackTrace) => Future.error(error, stackTrace)).

  7. Xgamefactory commented on May 9, 2020

    @Xgamefactory

    get same error while calling dio.delete with lates dio package.

    An error occurred. type 'Future<Response<dynamic>>' is not a subtype of type 'Response<dynamic>'

  8. shliama commented on May 29, 2020

    @shliama

    I was getting this error too, right after adding token refresh InterceptorsWrapper. I noticed that this error occurs when Dio is locked.

    An error occurred. type 'Future<Response<dynamic>>' is not a subtype of type 'Response<dynamic>'

    In order to fix it, I changed the signature of _dispatchRequest method inside Dio.dart from

    FutureOr<Response<T>> _dispatchRequest<T>(RequestOptions options)

    to

    FutureOr _dispatchRequest<T>(RequestOptions options)

    P.S. I have no idea what I'm doing :(

  9. eelishiram commented on Aug 24, 2020

    @eelishiram

    this error happens again in latest version of dio (v.3.0.10)

  10. aboutlan commented on Apr 13, 2021

    @aboutlan

    I ran into the same error when locked. Has anyone solved this error?

  11. codekeyz commented on Oct 12, 2021

    @codekeyz

    @eelishiram @aboutlan This PR: #1296 fixes this.

  12. added a commit that references this issue on Feb 13, 2023
  13. added a commit that references this issue on Jun 11, 2025
  14. added a commit that references this issue on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions