getConfigurations method

List<SamplingConfiguration> getConfigurations({
  1. required List<String> types,
})

Returns a list of copies of SamplingConfigurations from this schema for a list of types.

Implementation

List<SamplingConfiguration> getConfigurations({required List<String> types}) {
  List<SamplingConfiguration> configurationList = [];

  // since we're using json serialization below, make sure that the json
  // functions have been registred
  CarpMobileSensing();

  for (var type in types) {
    if (configurations.containsKey(type)) {
      // clone the measure object
      final configurationAsJson = _encode(configurations[type]);
      final SamplingConfiguration configurationClone =
          SamplingConfiguration.fromJson(
              json.decode(configurationAsJson) as Map<String, dynamic>);
      configurationList.add(configurationClone);
    }
  }

  return configurationList;
}