I use simpletimer package, and it has required duration. So when I try to set Duration(minutes: 5, hours: 1) for example, it shows 65 minutes. So I want to show to user 01:05:00 or 1:05:00 like this. How can I do this?
I found somethings like:
format(Duration d) => d.toString().split('.').first.padLeft(8, "0");
but it gives
"string is not subtype of duration."
So I am stuck. Help.
My simleTimer:
SimpleTimer(
progressTextStyle: const TextStyle(fontSize: 35),
status: TimerStatus.pause,
duration: format(Duration(hours: 1, minutes: 3))),
CodePudding user response:
I think you should use the progressTextFormatter
argument of the default SimpleTimer
constructor.
You can look at the source code to have an example of how to do it: here's the link
A quick example:
SimpleTimer(
progressTextFormatter: (Duration d) => "${duration.inMinutes % 60}:${duration.inMinutes}:${(duration.inSeconds % 60).toString().padLeft(2, "0")}",
//...rest of the constructor