isProfileActive method

  1. @protected
bool isProfileActive(
  1. String profile
)

Checks Profile Activation

Determines whether the specified profile is currently active.

Behavior

  • Validates the profile using validateProfile.
  • If the active profiles set is non-empty, checks membership directly.
  • If no profiles are active, falls back to checking default profiles.

Returns

  • true if the profile is active or part of the defaults.
  • false otherwise.

Example

if (isProfileActive('prod')) {
  enableProductionMode();
}

Notes

  • Case sensitivity depends on the environment’s profile handling.

Implementation

@protected
bool isProfileActive(String profile) {
  validateProfile(profile);
  Set<String> currentActiveProfiles = doGetActiveProfiles();
  return (currentActiveProfiles.contains(profile) ||
      (currentActiveProfiles.isEmpty && doGetDefaultProfiles().contains(profile)));
}