startTimer method
Implementation
Future<void> startTimer(int sec) async {
try {
clockTimer = Duration(seconds: sec).obs;
secondsRemaining.value = sec;
timer != null && timer!.isActive ? timer?.cancel() : null;
timer = Timer.periodic(const Duration(seconds: 1), (_) {
if (secondsRemaining.value != 0) {
secondsRemaining.value--;
// print("objectTimer 3 ${secondsRemaining.value}");
clockTimer.value = Duration(seconds: secondsRemaining.value);
} else {
isResend.value = true;
timer?.cancel();
// Get.off(() => const OutletDashBoard(
// ));
}
});
} catch (e) {
// Handle network errors
}
}