setEnvironments static method

void setEnvironments(
  1. List<DebugEnvironment> environments, {
  2. bool enabled = kDebugMode,
})

Sets environments for every Dio that doesn't pass its own list to addDebugLogger. Call it in main() so the switcher is available before the first request (useful when Dio is created lazily).

Does nothing when enabled is false (release builds by default).

Implementation

static void setEnvironments(
  List<DebugEnvironment> environments, {
  bool enabled = kDebugMode,
}) {
  if (!enabled) return;
  ReleaseGuard.check('Environment switching');
  DebugEnvironments.instance.setGlobal(environments);
}