addSection method

void addSection(
  1. String? section,
  2. ConfigParams? sectionParams
)

Adds parameters into this ConfigParams under specified section. Keys for the new parameters are appended with section dot prefix.

  • section name of the section where add new parameters
  • sectionParams new parameters to be added.

Implementation

void addSection(String? section, ConfigParams? sectionParams) {
  if (section == null) throw Exception('Section name cannot be null');

  if (sectionParams != null) {
    for (var key in sectionParams.getKeys()) {
      var name = key;

      if (name.isNotEmpty && section.isNotEmpty) {
        name = section + '.' + name;
      } else if (name.isEmpty) {
        name = section;
      }

      var value = sectionParams[key];

      put(name, value);
    }
  }
}