# EnvironmentAware class abstract interface

🫘 Interface for components that can be configured with an Environment.

The EnvironmentAware interface allows components to access and interact with the application's environment configuration, including profiles, property sources, and configuration metadata.

### Environment Capabilities:

- Profile Management: Check active and default profiles
- Property Resolution: Access configuration properties from various sources
- Configuration Detection: Determine application configuration state
- Feature Toggling: Enable/disable features based on environment

### Framework Integration:

- Called during component initialization with non-null Environment
- The environment is fully configured with all property sources
- Profiles are activated and property resolution is operational

### Example Usage:

    @Component
    class EnvironmentAwareService implements EnvironmentAware {
      late Environment _environment;

      @override
      void setEnvironment(Environment environment) {
        _environment = environment;
      }

      bool isFeatureEnabled(String featureName) {
        return _environment.getProperty(
          'features.$featureName.enabled',
          bool.fromString,
          defaultValue: false
        );
      }

      String getDataSourceUrl() {
        return _environment.getRequiredProperty('datasource.url');
      }

      bool isDevelopment() {
        return _environment.acceptsProfiles({'development'});
      }

      bool isProduction() {
        return _environment.acceptsProfiles({'production'});
      }
    }

### Best Practices:

- Use for environment-specific configuration, not business logic
- Provide sensible default values for optional properties
- Use `getRequiredProperty` for mandatory configuration
- Consider using `@ConfigurationProperties` for structured configuration

See also:

- Environment for the environment interface
- ApplicationContextAware for alternative environment access
- `ConfigurationProperties` for type-safe configuration binding

## Properties

hashCode → int
  The hash code for this object.
  no setter inherited
runtimeType → Type
  A representation of the runtime type of the object.
  no setter inherited

## Methods

noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
setEnvironment(Environment environment) → void
  Sets the Environment that this component runs in.
toString() → String
  A string representation of this object.
  inherited

## Operators

operator ==(Object other) → bool
  The equality operator.
  inherited