Work.fromJson constructor

Work.fromJson(
  1. Map<String, dynamic> json
)

The default constructor.

Implementation

factory Work.fromJson(Map<String, dynamic> json) {
  final String? endDate = json['endDate'] as String?;
  final String? startDate = json['startDate'] as String?;

  // TODO: company size should be an int, not a double.
  final double? companySize = json['companySize'] as double?;

  return Work._(
    company: json['company'] as String?,
    companyID: json['companyID'] as String?,
    companySize: companySize?.toInt(),
    description: json['description'] as String?,
    endDate: endDate == null ? null : DateTime.tryParse(endDate),
    industry: json['industry'] as String?,
    isCurrent: json['isCurrent'] as bool?,
    location: json['location'] as String?,
    startDate: startDate == null ? null : DateTime.tryParse(startDate),
    title: json['title'] as String?,
  );
}