FocusProfile.fromJson constructor
Restores a profile from JSON-compatible values.
Implementation
factory FocusProfile.fromJson(Map<String, Object?> json) {
return FocusProfile(
currentStreak: json['currentStreak'] as int? ?? 0,
longestStreak: json['longestStreak'] as int? ?? 0,
totalPoints: json['totalPoints'] as int? ?? 0,
totalExperience: json['totalExperience'] as int? ?? 0,
completedSessions: json['completedSessions'] as int? ?? 0,
cancelledSessions: json['cancelledSessions'] as int? ?? 0,
totalFocusedDuration: Duration(
seconds: json['totalFocusedDuration'] as int? ?? 0,
),
lastCompletedDate: json['lastCompletedDate'] == null
? null
: DateTime.parse(json['lastCompletedDate'] as String),
lastActivityDate: json['lastActivityDate'] == null
? null
: DateTime.parse(json['lastActivityDate'] as String),
currentLevel: json['currentLevel'] as int? ?? 1,
);
}