init<T> static method

void init<T>({
  1. required EnvironmentType environmentType,
  2. required T config,
  3. DebugOptions debugOptions = const DebugOptions(),
})

Initialize the environment from configuration model and store it in entrypoint file.

Params: environmentType The environment type that you want to initialize the environment with. config Environment variables debugOptions An optional parameter that allows you to specify the debug options for the environment.

Throws an Exception when Environment already initialized.

Implementation

static void init<T>({
  required EnvironmentType environmentType,
  required T config,
  DebugOptions debugOptions = const DebugOptions(),
}) {
  if (_instance == null) {
    _instance = Environment<T>._(
      environmentType: environmentType,
      debugOptions: debugOptions,
      config: config,
    );
  } else {
    throw Exception('Environment already initialized');
  }
}