parseObjects<T> method

List<T> parseObjects<T>(
  1. T? transform(
    1. dynamic
    )
)

Parses a JSONArray of JSONObject into a List of models using the given transform.

Implementation

List<T> parseObjects<T>(T? Function(dynamic) transform) {
  if (this == null || this!.isEmpty) {
    return [];
  }
  List<T> models = [];
  for (dynamic element in this!) {
    T? model = transform(element);
    if (model != null) {
      models.add(model);
    }
  }
  return models;
}