getHeaderForREST static method

Map<String, String> getHeaderForREST({
  1. RequestType requestType = RequestType.getReq,
  2. String token = "",
})

Implementation

static Map<String, String> getHeaderForREST({
  RequestType requestType = RequestType.getReq,
  String token = "",
}) {
  switch (requestType) {
    case RequestType.postReq:
      return {
        keyAccept: applicationJson,
        keyContentType: applicationJson,
      };
    case RequestType.getReq:
      return {
        keyAccept: applicationJson,
      };
    case RequestType.postWithAuthReq:
      return {
        keyAccept: applicationJson,
        keyContentType: applicationJson,
        keyAuthorization: "Bearer $token"
      };
    case RequestType.getWithAuthReq:
      return {
        keyAccept: applicationJson,
        keyAuthorization: "Bearer $token",
      };
  }
}