getPropKey method
Returns the key used to store the prop read within accessProp
.
For example:
class FooProps = UiProps with FooPropsMixin, BarPropsMixin;
mixin FooPropsMixin on UiProps {
String? foo;
}
mixin BarPropsMixin on UiProps {
String? bar;
}
void example(FooProps props) {
props.getPropKey((p) => p.foo); // 'FooPropsMixin.foo'
props.getPropKey((p) => p.bar); // 'BarPropsMixin.bar'
props.getPropKey((p) => p.onClick); // 'onClick'
}
Similar to the top-level prop_key_util.getPropKey utility, but can be done on an existing props object as opposed to needing to pass in the factory, and has better generic inference before 2.18.
// Top-level method
getPropKey<FooProps>((p) => p.foo, Foo);
// This utility:
props.getPropKey((p) => p.foo);
Implementation
String getPropKey(void Function(T) accessProp) =>
// ignore: invalid_use_of_visible_for_overriding_member
$getPropKey((map) => accessProp(map as T));