title: How can I activate and deactivate a button after countdown on Flutter?
body: <p>I would like to deactivate a button during a countdown. After countdown finishes button will be activated automatically.</p>
  
  <p>How can I do it?</p>
  
  <p>Below you could find code for timer. When this timer finishes I would like to activate a button</p>
  
  <pre><code> import 'dart:async';
  
   import 'package:flutter/material.dart';
  
    class OtpTimer extends StatefulWidget {
    @override
    _OtpTimerState createState() =&gt; _OtpTimerState();
       }
  
   class _OtpTimerState extends State&lt;OtpTimer&gt; {
    final interval = const Duration(seconds: 1);
  
     final int timerMaxSeconds = 60;
  
     int currentSeconds = 0;
  
       String get timerText =&gt;
        '${((timerMaxSeconds - currentSeconds) ~/ 60).toString().padLeft(2,'0')}: ${((timerMaxSeconds - currentSeconds) % 60).toString().padLeft(2,'0')}';
  
     startTimeout([int milliseconds]) {
        var duration = interval;
       Timer.periodic(duration, (timer) {
       setState(() {
         print(timer.tick);
        currentSeconds = timer.tick;
         if (timer.tick &gt;= timerMaxSeconds) timer.cancel();
       });
       });
     }
  
     @override
     void initState() {
    startTimeout();
       super.initState();
       }
  
      @override
      Widget build(BuildContext context) {
          return Row(
       mainAxisSize: MainAxisSize.min,
      children: &lt;Widget&gt;[
        Icon(Icons.timer),
        SizedBox(
         width: 5,
         ),
       Text(timerText)
        ],
     );
      }
    }
  </code></pre>