title: Pause Flutter Countdown Timer
body: <p>I have been playing with Dart Timer Class that I got it to work in its very basic form, however I am stuck trying to add a pause function to it. I have looked into their documentations, but their is not much about their Timer class...</p>
  
  <p>Is there any way I can pause and resume the timer/countdown on click? This is what I have achieved so far:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'dart:async';
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MyHomePage(title: 'Flutter Demo Home Page'),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    MyHomePage({Key key, this.title}) : super(key: key);
  
    final String title;
  
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
  
    Timer _timer;
    int _start = 10;
  
    void startTimer() {
      const oneSec = const Duration(seconds: 1);
      _timer = new Timer.periodic(
          oneSec,
              (Timer timer) =&gt; setState(() {
            if (_start &lt; 1) {
              timer.cancel();
            } else {
              _start = _start - 1;
            }
          }));
    }
  
  
    Widget build(BuildContext context) {
      return new Scaffold(
          appBar: AppBar(title: Text("Timer test")),
          body: Column(
            children: &lt;Widget&gt;[
              RaisedButton(
                onPressed: () {
                  startTimer();
                },
                child: Text("start"),
              ),
              Text("$_start")
            ],
          ));
    }
  }
  </code></pre>