[英]unable to use both useFuture() and useValueChanged() in same HookWidget
I have a hook widget with useValueChanged
listener as follows:我有一个带有
useValueChanged
侦听器的挂钩小部件,如下所示:
useValueChanged(selectedLayout.value, (_, __) {
changeLayout(selectedLayout.value);
});
and changeLayout(..)
uses useFuture(..)
to make a graphql mutation call and return a Future wrapped inside a AsyncSnapshot
并且
changeLayout(..)
使用useFuture(..)
进行 graphql 突变调用并返回包装在AsyncSnapshot
中的 Future
the value is changed in onTap
callback as follows:该值在
onTap
回调中更改如下:
onTap: () {
selectedLayout.value = "classic";
},
my HookWidget is throwing type mismatch error.我的 HookWidget 抛出类型不匹配错误。 any way to use
useFuture()
and useValueChanged()
in same HookWidget?在同一个 HookWidget 中使用
useFuture()
和useValueChanged()
的任何方法?
Bad state: Type mismatch between hooks:
- previous hook: _ValueChangedHook<String, Null>
- new hook: _FutureHook<QueryResult>
I was stuck in useValueChanged
but I got the way to do it.我被困在
useValueChanged
中,但我有办法做到这一点。 Here is the code:这是代码:
useValueChanged(state, (_, __) {
return controller.animateTo(
min(controller.position.maxScrollExtent, controller.offset + 50.0),
duration: Duration(seconds: 10),
curve: Curves.linear);
});
This worked fine for me.这对我来说很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.