ensureProperty<TValue> method

BindableProperty<TValue> ensureProperty<TValue>(
  1. Object propertyKey, {
  2. TValue? initialValue,
})

确认指定 propertyKey 对应的绑定属性

  • 如对应属性不存在,且 initialValue 不为 null 则使用 initialValue 注册一个值绑定属性 否则抛出异常

propertyKey 属性键

Implementation

BindableProperty<TValue> ensureProperty<TValue>(Object propertyKey,
    {TValue? initialValue}) {
  var property =
      getProperty<TValue>(propertyKey, required: initialValue == null);
  if (property == null && initialValue != null) {
    property = PreBindableProperty(initialValue: initialValue);
    registerProperty(propertyKey, property);
  }
  return property!;
}