ApiResponse<T extends dynamic> constructor
ApiResponse<T extends dynamic>(
- dynamic obj, {
- String? dataPath,
- String? errorPath,
})
Implementation
ApiResponse(dynamic obj, {String? dataPath, String? errorPath}) {
if ((errorPath ?? Api.globalErrorPath) != null)
this._error = _jsonValue(errorPath ?? Api.globalErrorPath!, obj);
if (isSuccess) {
if ((dataPath ?? Api.globalDataPath) != null) {
this._data = _jsonValue(dataPath ?? Api.globalDataPath!, obj);
} else {
this._data = obj;
}
if (_data is Iterable) {
_dataCount = (_data as Iterable).length;
} else if (_data is Map) {
_dataCount = (_data as Map).length;
} else {
_dataCount = 0;
}
}
}