BaseModel.fromJson constructor

BaseModel.fromJson(
  1. Map<String, dynamic>? json,
  2. ExtendedResponse response
)

Implementation

BaseModel.fromJson(Map<String, dynamic>? json, ExtendedResponse response) {
  statusCode = response.statusCode;
  statusMessage = response.statusMessage;
  code = statusCode.toString();
  msg = '服务器异常';
  original = response;
  if (json != null) {
    final dioOptions = BaseDio().baseDioOptions;
    final codeValue = _getValue(dioOptions.codeKeys, json);
    if (codeValue != null) code = codeValue!.toString();
    final msgValue = _getValue(dioOptions.msgKeys, json);
    if (msgValue != null) msg = msgValue!.toString();
    data = _getValue(dioOptions.dataKeys, json);
    extension = _getValue(dioOptions.extensionKeys, json);
  }
}