我想拥有ValueNotifierBuilder,但目前不存在。有什么计划要添加吗?
答案 0 :(得分:3)
有ValueListenableBuilder
似乎正是您要寻找的。 p>
它从任何ValueListenable
(ValueNotifier
是一个)重建。
ValueListenableBuilder(
valueListenable: valueNotifier,
builder: (context, value, child) {
return Text('$value');
})
https://docs.flutter.io/flutter/widgets/ValueListenableBuilder-class.html
答案 1 :(得分:0)
编辑:
现在它已以ValueListenableBuilder
的名称添加到框架中
已经有一个,但名称不是ValueNotifierBuilder
。
它是AnimatedBuilder
,与任何Listenable
兼容。 ValueNotifier
是一个(但ScrollController
也很多)。
AnimatedBuilder(
animation: valueNotifier,
builder: (context, child) {
return Column(
children: <Widget>[
Text(valueNotifier.value.toString()),
child,
],
);
},
child: Text("Hello World")
)