getPropertyForKey method

JSValue getPropertyForKey(
  1. String propertyKey, {
  2. bool autoDispose = true,
})

Gets a property from an object using a JSValueRef as the property key. // iOS 13.0 This function is the same as performing "objectpropertyKey" from JavaScript. propertyKey A JSValueRef containing the property key to use when looking up the property. exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.

Implementation

JSValue getPropertyForKey(String propertyKey, {bool autoDispose = true}) {
  final JSException exception = JSException.create(context);
  final JSValue jspropKey = JSValue.makeString(context, propertyKey);
  final JSValueRef ret = JSObjectGetPropertyForKey(
    context.ref,
    _ref,
    jspropKey.ref,
    exception.ref,
  );
  if (exception.shouldThrow) throw exception.error;
  return JSValue(context, ret, autoDispose: autoDispose);
}