get method

  1. @override
Object? get(
  1. String name
)
override

Accesses a property or method of this value.

Implementation

@override
Object? get(String name) {
  // 1. Check if it's a BRIDGED instance METHOD
  final methodAdapter = bridgedClass.findInstanceMethodAdapter(name);
  if (methodAdapter != null) {
    // Return a Callable bound to this instance and the adapter
    return BridgedMethodCallable(this, methodAdapter, name);
  }

  // RC-7: If the wrapped native object is an Enum, handle .name and .index
  // This covers cases where a bridged getter returns a native enum value
  // wrapped in BridgedInstance (e.g., paint.blendMode returns BlendMode.srcOver
  // as a BridgedInstance, then .name is requested).
  if (nativeObject is Enum) {
    switch (name) {
      case 'name':
        return (nativeObject as Enum).name;
      case 'index':
        return (nativeObject as Enum).index;
    }
  }

  // This should be handled by visitors (PrefixedIdentifier, PropertyAccess)
  // for them to have access to the visitor if necessary.
  // The logic here is simplified and could be incorrect if a getter
  // would need to be returned as a value.

  // 3. If neither method nor getter found, throw an error
  throw RuntimeD4rtException(
    "Undefined property or method '$name' on bridged instance of '${bridgedClass.name}'",
  );
}