ApiLayer constructor

ApiLayer({
  1. required Map<String, dynamic> env,
  2. Map<String, String>? customHeader,
  3. String? bearerToken,
  4. BuildContext? context,
  5. bool skipLoading = false,
})

Implementation

ApiLayer({required Map<String, dynamic> env, Map<String, String>? customHeader, String? bearerToken, BuildContext? context, bool skipLoading = false}) {
  Map<String, String> localHeader = customHeader ?? {};
  localHeader["Content-Type"] = "application/json";
  if(bearerToken != null) { localHeader['Authorization'] = 'Bearer $bearerToken'; }
  if(env["API_TOKEN"] != null) { localHeader["Api-Token"] = env["API_TOKEN"]!; }
  if(env["ENVIRONMENT"] != null) { environment = env["ENVIRONMENT"]!; }
  if(context != null) {
    this.context = context;
    if(!skipLoading) {
      loading = Loading(text: 'Carregando...', context: context,);
      loading!.showOverlay();
    }
  }
  if((env['skipFingerPrint'] ?? false)) { skipFingerPrintValidation = true; }
  urlBase = "${env['HTTP_BASE']!}${env['URL_BASE']!}";
  header = localHeader;
}