getFieldObjectFromDartObject function

DartObject? getFieldObjectFromDartObject(
  1. DartObject obj,
  2. String fieldName
)

Implementation

DartObject? getFieldObjectFromDartObject(DartObject obj, String fieldName) {
  // Traverse the inheritance chain to find the field
  DartObject? currentObj = obj;
  while (currentObj != null) {
    final field = currentObj.getField(fieldName);
    if (field != null) {
      return field;
    }
    currentObj = currentObj.getField('(super)');
  }
  return null;
}