getPropertyOf<TValue, TProperty extends BindableProperty<TValue>> method

TProperty? getPropertyOf<TValue, TProperty extends BindableProperty<TValue>>(
  1. Object propertyKey, {
  2. bool required = false,
})

获取指定 propertyKey 对应 TProperty 类型属性

propertyKey 属性键

required 指定 propertyKey 对应属性是否必须存在, 且类型必须为 TProperty, 其值为 true 时, 如 propertyKey 对应属性不存在 或其类型不为 TProperty, 则抛出异常 默认值为 false

Implementation

TProperty? getPropertyOf<TValue, TProperty extends BindableProperty<TValue>>(
    Object propertyKey,
    {bool required = false}) {
  var property = getProperty<TValue>(propertyKey, required: required);
  if (property is TProperty) return property;
  if (required) throw NotOfTypePropertyException(propertyKey, TProperty);
  return null;
}