ResponseParser class abstract

响应解析器接口 用户必须实现此接口来定义如何将原始 HTTP 响应转换为用户定义的 Response

示例:

class MyResponseParser implements ResponseParser {
  @override
  Response<T> parse<T>(RawHttpResponse raw) {
    final data = raw.data as Map<String, dynamic>;
    return MyResponse(
      success: data['status'] == 'success',
      error: data['error'] as String?,
      payload: data['result'] as T?,
    );
  }
}
Implementers

Constructors

ResponseParser()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse<T>(RawHttpResponse raw) Response<T>
解析响应 raw 原始 HTTP 响应(statusCode、data、path) 返回用户定义的 Response,必须处理所有可能的响应结构
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited