child<Z extends DataClass> method

DataSet<Z> child<Z extends DataClass>({
  1. String relationName = 'default',
  2. dynamic parentId,
  3. bool clear = true,
})

Returns the dataset that was stored as a child under the relation name passed as parameter

Implementation

DataSet<Z> child<Z extends DataClass>(
    {String relationName = 'default', dynamic parentId, bool clear = true}) {
  if (_children[Z] != null && _children[Z]!.containsKey(relationName)) {
    var child = _children[Z]![relationName] as DataSet<Z>;
    child._route = child.options.route;
    if (parentId != null) {
      child._route = child.route.replaceAll(':parentId', parentId);
    }
    if (clear) {
      child.list.clear();
      child.data = child.builder.call();
      child.local = {};
      child.localViews = {};
    }
    return child;
  }
  throw Exception(
      'The dataset relation of type "$Z" and name "$relationName" does not exist!');
}