PulseResult.generate constructor

PulseResult.generate(
  1. Map<String, dynamic>? result
)

Constructs a PulseResult from a map representation of the result.

This factory constructor parses the map result to extract information about unsupported features. If result is null, or does not contain information about unsupported features, an empty PulseResult is returned.

Implementation

factory PulseResult.generate(Map<String, dynamic>? result) {
  if (result == null) return PulseResult._empty();

  final unsupportedWorkoutTypes = result['unsupportedWorkoutTypes'] as List?;
  final List<PulseWorkoutType> unsupportedFeatures = unsupportedWorkoutTypes != null
      ? unsupportedWorkoutTypes.cast<String>().map(PulseWorkoutType.values.byName).toList()
      : [];

  return PulseResult._(unsupportedWorkoutTypes: unsupportedFeatures);
}