fromJson static method
Factory constructor to parse a JSON map and status code into a ServerErrorResponse object.
Returns null
if the statusCode
is not 500
, indicating this is not a server error.
Example:
final response = ServerErrorResponse.fromJson(jsonMap, 500);
Implementation
static ServerErrorResponse? fromJson(
Map<String, dynamic> json, int statusCode) {
return statusCode == 500
? ServerErrorResponse(
code: json['code'],
message: json['message'],
statusCode: statusCode,
)
: null;
}