ApiResponse<T extends dynamic> constructor

ApiResponse<T extends dynamic>(
  1. dynamic obj, {
  2. String? dataPath,
  3. 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;
    }
  }
}