I am using dio
on my ApiRepository
class. But there is an error showing on this line
_dio.get(this.url, queryParameters: this.payload).then((response) {...
the argument type 'map dynamic dynamic ' can't be assigned to the parameter type 'map string dynamic'
Full Class
class ApiRepository {
final String url;
final Map payload;
ApiRepository(this.url, this.payload);
final Dio _dio = Dio();
void get({
required Function() beforeSend,
required Function(dynamic data) onSuccess,
required Function(dynamic error) onError,
}) {
_dio.get(this.url, queryParameters: this.payload).then((response) {
if (onSuccess != null) {
onSuccess(response.data);
}
}).catchError((error) {
if (onError != null) {
onError(error);
}
});
}
}
queryParameters
requires Map<String, dynamic>
but default Map
is Map<dynamic, dynamic>
.
Change payload
map tofinal Map<String, dynamic> payload;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.