bodyAsList<T extends DataModel> method

List<T> bodyAsList<T extends DataModel>(
  1. Type type
)

Convert response body to a list of DataModel

Implementation

List<T> bodyAsList<T extends DataModel>(Type type) {
  var result = <T>[];

  if (data is List) {
    for (var element in data) {
      var model = DataModel.create<T>(type);
      model.fromJSON(element);
      result.add(model);
    }
  }

  return result;
}