$watchFor<TValue> method

Widget $watchFor<TValue>(
  1. Object propertyKey, {
  2. required ValueWidgetBuilder<TValue> builder,
  3. Widget? child,
  4. TValue? initialValue,
})

绑定到指定属性, 当 propertyKey 对应属性值发生变化时, 使用 builder 构建 Widget

child 用于向构建方法中传入 Widget

// example
@override
Widget build(BuildContext context) {
  return $watchFor<String>(#account,
    builder: (context, value, child) => Text(value));
}

Implementation

Widget $watchFor<TValue>(Object propertyKey,
        {required ValueWidgetBuilder<TValue> builder,
        Widget? child,
        TValue? initialValue}) =>
    $watch(ensureProperty<TValue>(propertyKey, initialValue: initialValue),
        builder: builder, child: child);