getHttpDefaultHeaders method

Map<String, String> getHttpDefaultHeaders({
  1. String? contentType,
  2. Map<String, String>? otherHeaders,
})

Method used to make Http calls. Conveniently placed in this class to facilitate overrides.

Implementation

Map<String, String> getHttpDefaultHeaders(
    {String? contentType, Map<String, String>? otherHeaders}) {
  final headers = <String, String>{};

  if (contentType != null && contentType.isNotEmpty) {
    headers["Content-Type"] = contentType;
  }

  final accessToken = Lowder.globalVariables["access_token"];
  if (accessToken != null && accessToken.isNotEmpty) {
    headers["Authorization"] = "Bearer $accessToken";
  }

  if (otherHeaders != null) {
    headers.addAll(otherHeaders);
  }

  return headers;
}