3

In my flutter app I'm playing an animation. And I want to start the playback only after all the widgets on the page have loaded. Essencially I'm looking for the JS equivalnat of window.onload in flutter. Right now the animation starts as soon as it can and the result it that when the app lunches I see a white screen while the app is loading for a few seconds and when the app is finally loaded the animation is already half way through the playback.

Is there a signal or event in flutter that will let me know that the app has loaded?

intrepidis
  • 2,870
  • 1
  • 34
  • 36
Curtwagner1984
  • 1,908
  • 4
  • 30
  • 48

1 Answers1

5

In a widget you can use

WidgetsBinding.instance.addPostFrameCallback((_){
  //stuff
})

If you put this in your initState the callback will be called after the first frame is rendered, if that's what you need.

magicleon94
  • 4,887
  • 2
  • 24
  • 53