UserData.fromJson constructor
UserData.fromJson(
- Map<String, dynamic> json
)
Implementation
factory UserData.fromJson(Map<String, dynamic> json) {
return UserData(
gender: json['gender'] as String,
weight: (json['weight'] as num).toDouble(),
height: (json['height'] as num).toDouble(),
timeFormat: json['timeFormat'] as String,
birthDate: DateTime.parse(json['birthDate'] as String),
measurementSystem: json['measurementSystem'] as String,
activityLevel: json['activityLevel'] as int?,
handedness: json['handedness'] as String,
powerFormat: PowerFormat.fromJson(
json['powerFormat'] as Map<String, dynamic>,
),
heartRateFormat: PowerFormat.fromJson(
json['heartRateFormat'] as Map<String, dynamic>,
),
firstDayOfWeek: FirstDayOfWeek.fromJson(
json['firstDayOfWeek'] as Map<String, dynamic>,
),
vo2MaxRunning: (json['vo2MaxRunning'] as num?)?.toDouble(),
vo2MaxCycling: (json['vo2MaxCycling'] as num?)?.toDouble(),
lactateThresholdSpeed:
(json['lactateThresholdSpeed'] as num?)?.toDouble(),
lactateThresholdHeartRate:
(json['lactateThresholdHeartRate'] as num?)?.toDouble(),
diveNumber: json['diveNumber'] as int?,
intensityMinutesCalcMethod: json['intensityMinutesCalcMethod'] as String,
moderateIntensityMinutesHrZone:
json['moderateIntensityMinutesHrZone'] as int,
vigorousIntensityMinutesHrZone:
json['vigorousIntensityMinutesHrZone'] as int,
hydrationMeasurementUnit: json['hydrationMeasurementUnit'] as String,
hydrationContainers: List<Map<String, dynamic>>.from(
json['hydrationContainers'] ?? [],
),
hydrationAutoGoalEnabled: json['hydrationAutoGoalEnabled'] as bool,
firstbeatMaxStressScore:
(json['firstbeatMaxStressScore'] as num?)?.toDouble(),
firstbeatCyclingLtTimestamp: json['firstbeatCyclingLtTimestamp'] as int?,
firstbeatRunningLtTimestamp: json['firstbeatRunningLtTimestamp'] as int?,
thresholdHeartRateAutoDetected:
json['thresholdHeartRateAutoDetected'] as bool?,
ftpAutoDetected: json['ftpAutoDetected'] as bool?,
trainingStatusPausedDate: json['trainingStatusPausedDate']?.toString(),
weatherLocation: json['weatherLocation'] == null
? null
: WeatherLocation.fromJson(
json['weatherLocation'] as Map<String, dynamic>,
),
golfDistanceUnit: json['golfDistanceUnit']?.toString(),
golfElevationUnit: json['golfElevationUnit']?.toString(),
golfSpeedUnit: json['golfSpeedUnit']?.toString(),
externalBottomTime: (json['externalBottomTime'] as num?)?.toDouble(),
);
}