read static method

ApiBase read(
  1. BuildContext context
)

A wrapper around context.read, it should be used instead of it.

Performs a context.read<ApiBase>() to get ApiBase from the context, set the current context of the ApiBase to context then return the ApiBase

Implementation

static ApiBase read(BuildContext context) {
  final ApiBase apiBase = context.read<ApiBase>();
  apiBase._currentBuildContext = context;
  apiBase._defaultHeaders ??= {};
  apiBase._defaultHeaders!["Accept-Language"] =
      context.read<LanguageProvider>().locale?.languageCode ?? "fr";
  return apiBase;
}