get method

Future get(
  1. String path, {
  2. Map<String, dynamic>? params,
  3. Options? options,
  4. CancelToken? cancelToken,
  5. bool refresh = false,
  6. bool noCache = !CACHE_ENABLE,
  7. String? cacheKey,
  8. bool cacheDisk = false,
  9. bool showToastOnError = true,
  10. bool showMask = false,
})

restful get 操作

Implementation

Future get(
  String path, {
  Map<String, dynamic>? params,
  Options? options,
  CancelToken? cancelToken,
  bool refresh = false,
  bool noCache = !CACHE_ENABLE,
  String? cacheKey,
  bool cacheDisk = false,
  bool showToastOnError = true,
  bool showMask = false,
}) async {
  Options requestOptions = options ?? Options();
  requestOptions = requestOptions.copyWith(extra: {
    "refresh": refresh,
    "noCache": noCache,
    "cacheKey": cacheKey,
    "cacheDisk": cacheDisk,
    toastOnError: showToastOnError,
    showMaskOnRequest: showMask,
  });
  Response response = await dio.get(
    path.startsWith('http') ? path : baseUrl + path,
    queryParameters: params,
    options: requestOptions,
    cancelToken: cancelToken ?? _cancelToken,
  );
  return response.data;
}