File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,6 @@ class Account {
4141 final String timestamp => DateTime .parse (timestamp),
4242 final int timestamp => DateTime .fromMillisecondsSinceEpoch (timestamp * 1000 ),
4343 final double timestamp => DateTime .fromMillisecondsSinceEpoch (timestamp.toInt () * 1000 ),
44- null => null ,
4544 _ => null ,
4645 };
4746
Original file line number Diff line number Diff line change @@ -16,12 +16,16 @@ class Work {
1616
1717 /// The default constructor.
1818 factory Work .fromJson (Map <String , dynamic > json) {
19+ final int ? companySize = switch (json['companySize' ]) {
20+ final int size => size,
21+ final double size => size.toInt (),
22+ _ => null ,
23+ };
24+
1925 return Work ._(
2026 company: json['company' ] as String ? ,
2127 companyID: json['companyID' ] as String ? ,
22- // We don't know if company size is an integer or a double here.
23- // Instead, cast it to num and call `toInt()` on the number instead.
24- companySize: (json['companySize' ] as num ? )? .toInt (),
28+ companySize: companySize,
2529 description: json['description' ] as String ? ,
2630 endDate: DateTime .tryParse (json['endDate' ] as String ? ?? '' ),
2731 industry: json['industry' ] as String ? ,
You can’t perform that action at this time.
0 commit comments