HttpConfig constructor

HttpConfig({
  1. required String baseUrl,
  2. ResponseParser? responseParser,
  3. Map<String, String>? staticHeaders,
  4. Future<Map<String, String>> dynamicHeaderBuilder()?,
  5. String? networkErrorKey,
  6. VoidCallback? on401Unauthorized,
  7. void onFailure(
    1. int? httpStatusCode,
    2. int? errorCode,
    3. String message
    )?,
  8. Duration errorDeduplicationWindow = const Duration(seconds: 5),
  9. bool enableLogging = false,
  10. bool logPrintBody = true,
  11. LogMode logMode = LogMode.complete,
  12. bool logShowRequestHint = true,
  13. BuildContext? contextGetter()?,
  14. Widget loadingWidgetBuilder(
    1. BuildContext context
    )?,
  15. DeduplicationConfig? deduplicationConfig,
  16. QueueConfig? queueConfig,
  17. Map<String, String>? serviceBaseUrls,
  18. UnauthorizedRetryConfig? unauthorizedRetry,
  19. bool disableReceiveTimeout = false,
  20. Duration? connectTimeout,
  21. Duration? sendTimeout,
})

Implementation

HttpConfig({
  required this.baseUrl,
  ResponseParser? responseParser, // 可选参数,默认使用 StandardResponseParser
  this.staticHeaders,
  this.dynamicHeaderBuilder,
  this.networkErrorKey,
  this.on401Unauthorized,
  this.onFailure,
  this.errorDeduplicationWindow = const Duration(seconds: 5),
  this.enableLogging = false,
  this.logPrintBody = true,
  this.logMode = LogMode.complete,
  this.logShowRequestHint = true,
  this.contextGetter,
  this.loadingWidgetBuilder,
  this.deduplicationConfig,
  this.queueConfig,
  this.serviceBaseUrls,
  this.unauthorizedRetry,
  this.disableReceiveTimeout = false,
  this.connectTimeout,
  this.sendTimeout,
}) : responseParser = responseParser ?? StandardResponseParser();