fromJson method

  1. @override
DateTime fromJson(
  1. String json
)

Implementation

@override
DateTime fromJson(String json) {
  // Extract the timestamp from the string
  final RegExp regex = RegExp(r'\/Date\((\d+)\)\/');
  final match = regex.firstMatch(json);

  if (match != null) {
    final timestamp = int.parse(match.group(1)!);
    // Convert the timestamp to a DateTime object
    return DateTime.fromMillisecondsSinceEpoch(timestamp);
  } else {
    throw const FormatException('Invalid date format');
  }
}