DataFieldParser<T> class
数据字段解析器 - 从响应的 data 字段中提取数据 适用于标准格式: { "code": 200, "data": {...}, "message": "success" }
功能:
- 验证业务状态码(默认启用)
- 提取指定字段(默认为 'data')
示例:
// 提取 data 字段
final parser = DataFieldParser<Map<String, dynamic>>();
// 自定义字段名
final parser = DataFieldParser<List>(fieldName: 'items');
// 不验证状态码
final parser = DataFieldParser<Map>(validateStatusCode: false);
- Implemented types
-
- DataParser<
T>
- DataParser<
Constructors
- DataFieldParser({String fieldName = NetworkConstants.fieldData, bool validateStatusCode = true})
Properties
- fieldName → String
-
数据字段名,默认为 'data'
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- validateStatusCode → bool
-
是否验证状态码,默认为 true
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parse(
dynamic rawData) → T -
解析数据
rawData原始响应数据 返回解析后的目标数据override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited