-1

I found this help on StatefulBuilder and it shows how to use setState to update things in a ModalBottomSheet. But I want to go one more step and make a timer to do this.

https://stackoverflow.com/a/56972160/559525

I create the timer like this inside the stateful builder:

var bottomSheetTimer = Timer.periodic(const Duration(milliseconds: 1000), (timer) {
  setState(() {
    currSeekTime += 1;
    print("here");
  });
});

This prints out every second but the setState() isn't within the "builder" so nothing in the bottom tab updates. But if I put it in the builder it creates a LOT of timers.

Any help would be appreciated!

Eradicatore
  • 1,501
  • 2
  • 20
  • 38

1 Answers1

0

The correct approach would be to create the Timer in the initState method, not build.

Lee3
  • 2,882
  • 1
  • 11
  • 19