MarcelGarus / marquee

A Flutter widget that scrolls text infinitely. Provides many customizations including custom scroll directions and velocities, pausing after every round and specifying custom durations and curves for accelerating and decelerating.
MIT License
274 stars 113 forks source link

Reset the animation programatically #67

Open TcBello opened 3 years ago

TcBello commented 3 years ago

Is there any way to reset the animation of the text programatically?

MarcelGarus commented 3 years ago

Currently, not that I know of. In the meantime, you can pass a key and change it, which should cause the widget to rebuild from the initial state.

osamasaeed commented 1 year ago

Currently, not that I know of. In the meantime, you can pass a key and change it, which should cause the widget to rebuild from the initial state.

I spend alot of time to reset animation to initial state. finally, your answer hint me to do it. Thanks, That is how I manage it. may be helpful for someone.

  Key _refreshKey = UniqueKey();

  void _handleLocalChanged() => setState((){ 
    _refreshKey = UniqueKey() 
  });

  Widget build(BuildContext context){
    return MaterialApp(
      key: _refreshKey ,
      ...
    )
  }