getFieldValue method

dynamic getFieldValue(
  1. String fieldName,
  2. dynamic entity
)

Returns the value of the field with the specified fieldName from the specified entity.

Implementation

dynamic getFieldValue(String fieldName, dynamic entity) {
  dynamic currentValue = entity;
  for (var subField in fieldName.split('.')) {
    currentValue = lookup(currentValue.runtimeType)
        .getFieldValue(subField, currentValue);
    if (currentValue == null) {
      return null;
    }
  }
  return currentValue;
}