keyForProp method

String keyForProp(
  1. void accessProp(
    1. TProps props
    )
)

Returns the string key of the factory prop accessed in accessProp, including the namespace if one exists.

Intended for use within propTypes.

Example:

mixin MyProps on UiProps {
  bool somePropKey;

  @Accessor(keyNamespace: '')
  @override
  String id;
}

class MyComponent extends UiComponent2<MyProps> {
  void someInstanceMethod() {
    print(keyForProp((p) => p.somePropKey)); // Prints "MyProps.somePropKey"
    print(keyForProp((p) => p.id)); // Prints "id"
  }
}

Implementation

String keyForProp(void Function(TProps props) accessProp) => prop_key_util.getPropKey(accessProp, typedPropsFactory);