Home > Enterprise >  How to turn seconds in minutes in Countdown flutter?
How to turn seconds in minutes in Countdown flutter?

Time:12-05

I have a countdown and I want to transform it into seconds => it should look like this => 05(minutes):00(seconds)

This is my code:

Countdown(
  seconds: 300, // 5 minutes
  controller: _timer,
  interval: Duration(seconds: 1),
  build: (BuildContext context, double time) => Text(
    "0${(time.toInt() / 60).round()}:${time.toInt()}", // It looks like this:  05:300
    style: const TextStyle(
      color: AppColors.gray9D9F9E,
      fontWeight: FontWeight.w500),
    ),
    onFinished: () {
      setState(() {
         _isResend = true;
      });
   },
),

CodePudding user response:

Can you try out

"0${(time.toInt() ~/ 60)}:${(time % 60)}",
  • Related