How to use useSingleTickerProvider
to create a widget that updates every frame?
#278
-
I'm trying to create a widget that updates every frame, but I'm not sure how to use For example, this code, which doesn't use
But when I try to update that code to use
... I get the following error:
So it seems I'm doing something wrong, but I haven't been able to figure out what I need to change. I am hoping someone could point me in the right direction. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You are creating a ticker each frame. Try placing the logic inside an useEffect with the provider as key (equivalent to a initState) useEffect(() {
final ticker = tickerProvider.createTicker(...)
ticker.start();
return () {
// logic to dispose the ticker
ticker.dispose();
};
}, [tickerProvider]); |
Beta Was this translation helpful? Give feedback.
You are creating a ticker each frame. Try placing the logic inside an useEffect with the provider as key (equivalent to a initState)