Created with <3 with dartpad.dev.
          Last active
          June 26, 2023 14:24 
        
      - 
      
- 
        Save yungwarlock/593f2ee5048ea5989ff4b916239da353 to your computer and use it in GitHub Desktop. 
    Dart Timer
  
        
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import 'dart:async'; | |
| void main() { | |
| int countDown = 60; | |
| bool shouldShowResend = false; | |
| Timer.periodic(const Duration(seconds: 1), (t) { | |
| print(formatTime(countDown)); | |
| print(shouldShowResend); | |
| }); | |
| Timer.periodic(const Duration(seconds: 1), (t) { | |
| if(countDown == 0) { | |
| shouldShowResend = true; | |
| return; | |
| } | |
| countDown--; | |
| }); | |
| } | |
| String formatTime(int period) { | |
| var minutes = (period ~/ 60).toString().padLeft(2, "0"); | |
| var seconds = (period % 60).toString().padLeft(2, "0"); | |
| return "$minutes:$seconds"; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment