getPropertyNames method

  1. @override
List<String> getPropertyNames()
override

Returns the full list of property names known to this PropertySource.

Subclasses must implement this method to return all available keys.

Example:

final propertyNames = mySource.getPropertyNames();
print(propertyNames); // ['host', 'port', 'username']

This is used internally by containsProperty and other introspection features.

Implementation

@override
List<String> getPropertyNames() {
  List<List<String>> namesList = ArrayList.withCapacity(_propertySources.length);
  for (PropertySource propertySource in _propertySources) {
    if (propertySource is! ListablePropertySource) {
      throw IllegalStateException("Failed to enumerate property names due to non-enumerable property source: $propertySource");
    }

    List<String> names = propertySource.getPropertyNames();
    namesList.add(names);
  }

  Set<String> allNames = HashSet();
  for (var names in namesList) {
    allNames.addAll(names);
  }

  return allNames.toList();
}