更新我们的开发环境之一,现在在这个问题上兜圈子。有没有人看过这本书,可以提供一些建议?非常感谢
正在调试模式下在sdk gphone 64 x86 64上启动lib/main.dart...正在运行Gradle任务“assembleDebug”... lib/RestClient/UserAllGameClient.g.dart:41:18:错误:无法将参数类型“RequestOptions”分配给参数类型“Options”。
- 'RequestOptions'来自'package:dio/src/options.dart'('../../Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/options.dart')。
- 'Options'来自'package:dio/src/options.dart'('../../Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/options.dart')。options:RequestOptions(^
Future<List<dynamic>> getUserAllGames() async {
const _extra = <String, dynamic>{};
SharedPreferences pref = await SharedPreferences.getInstance();
Map<String, String> headers = {
HttpHeaders.contentTypeHeader: "application/json",
HttpHeaders.authorizationHeader: "Bearer ${pref.getString("token")}",
};
final response = await _dio.get('game/all',
options: RequestOptions(
method: 'GET',
headers: headers,
extra: _extra,
baseUrl: baseUrl)
);
print(response);
return response.data;
}
}
3条答案
按热度按时间7xzttuei1#
您必须将
RequestOptions
更改为Options(Dio)
pwuypxnk2#
dart-dio有一个新的“null-safety”生成器:“dart-dio-next”https://openapi-generator.tech/docs/generators/dart-dio-next
好像很管用!
qgzx9mmu3#
我们必须继续使用
Options
。查看API document了解更多信息。以下是修改后的请求: