fieldsToEvaluate<T extends BaseModel> method

Iterable<String> fieldsToEvaluate<T extends BaseModel>(
  1. Iterable<String>? onlyFields,
  2. Iterable<String>? exceptFields
)

Returns the fields that exist in this model.

onlyFields and exceptFields can be used to limit the fields that are evaluated. The two are mutually exclusive and an error will be thrown if both are specified.

Implementation

Iterable<String> fieldsToEvaluate<T extends BaseModel>(
  Iterable<String>? onlyFields,
  Iterable<String>? exceptFields,
) {
  assert(
    onlyFields == null || exceptFields == null,
    'onlyFields and exceptFields cannot both be specified at the same time',
  );
  return fieldKeys.where((element) {
    if (onlyFields != null) {
      return onlyFields.contains(element);
    }
    if (exceptFields != null) {
      return !exceptFields.contains(element);
    }
    return true;
  });
}