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

使用范型兼容同一个请求返回不同数据类型 #416

Closed
1 task
mrcwl opened this issue Aug 14, 2019 · 2 comments
Closed
1 task

使用范型兼容同一个请求返回不同数据类型 #416

mrcwl opened this issue Aug 14, 2019 · 2 comments

Comments

@mrcwl
Copy link

mrcwl commented Aug 14, 2019

New Issue Checklist

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

Issue Info

Info Value
Platform Name ios / android
Platform Version e.g. 1.5.0 / 12.0 / 9.0
Dio Version 2.1.13
Android Studio / Xcode Version e.g. Android Studio 3.3.2 / Xcode 10.2.1
Repro rate e.g. all the time (100%) / sometimes x% / only once
Repro with our demo prj e.g. does it happen with our demo project?
Demo project link e.g. link to a demo project that highlights the issue

Issue Description and Steps

我的接口200时返回bool类型,但是400的时候返回的是一个json对象,我加入范型post
接口返回400的时候提示该错误:
flutter: #0 Dio._assureResponse (package:dio/src/dio.dart:1012:9)
#1 Dio.resolve. (package:dio/src/dio.dart:309:14)
#2 _rootRunUnary (dart:async/zone.dart:1132:38)
#3 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#4 _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#5 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#6 Future._propagateToListeners (dart:async/future_impl.dart:668:32)
#7 Future._completeWithValue (dart:async/future_impl.dart:483:5)
#8 Future._asyncComplete. (dart:async/future_impl.dart:513:7)
#9 _rootRun (dart:async/zone.dart:1124:13)
#10 _CustomZone.run (dart:async/zone.dart:1021:19)
#11 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#12 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
#13 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#14 _startMicrotaskLoop (dart:a<…>

@mrcwl
Copy link
Author

mrcwl commented Aug 14, 2019

image
似乎是responseres类型转换时出现问题

@wendux
Copy link
Contributor

wendux commented Aug 25, 2019

返回类型是动态的情况可以不指定类型参数,此时T为dynamic

@wendux wendux closed this as completed Aug 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants