validateHealthDataTypes method

bool validateHealthDataTypes()

Check if the sampling configuration contains a valid list of HealthDataType for the current platform (iOS or Android).

Removes any health data type(s) which are not supported on this platform.

Implementation

bool validateHealthDataTypes() {
  List<HealthDataType> toRemove = [];
  for (var type in samplingConfiguration.healthDataTypes) {
    // is this type supported on the current platform?
    bool supported = (Platform.isIOS)
        ? dataTypesIOS.contains(type)
        : dataTypesAndroid.contains(type);

    if (!supported) {
      warning(
          "$runtimeType - Health data type '$type' is not supported on this platform "
          "(${Platform.operatingSystem}). "
          "Type is ignored.");
      toRemove.add(type);
    }
  }
  // remove all types we don't support on this platform
  samplingConfiguration.healthDataTypes
      .removeWhere((element) => toRemove.contains(element));

  return true;
}