Skip to content

How to use useSingleTickerProvider to create a widget that updates every frame? #278

Answered by davidmartos96
elliotwaite asked this question in Q&A
Discussion options

You must be logged in to vote

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]);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@elliotwaite
Comment options

Answer selected by elliotwaite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants