Skip to content

taoyu65/flutter_timer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flutter_timer

A flutter timer that shows time duration from initial time.

Screenshot

Alt text

Example

        import 'package:flutter/material.dart';
        import 'package:flutter_timer/flutter_timer.dart';
        class TimerPage extends StatefulWidget {
          @override
          _TimerPageState createState() => _TimerPageState();
        }

        class _TimerPageState extends State<TimerPage> {
          bool running = false;
          @override
          Widget build(BuildContext context) {
            return Scaffold(
              body: Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    TikTikTimer(
                      initialDate: DateTime.now(),
                      running: running,
                      height: 150,
                      width: 150,
                      backgroundColor: Colors.indigo,
                      timerTextStyle: TextStyle(color: Colors.white, fontSize: 20),
                      borderRadius: 100,
                      isRaised: true,
                      tracetime: (time) {
                        // print(time.getCurrentSecond);
                      },
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      children: <Widget>[
                        RaisedButton(
                          child: Text(
                            'Start',
                            style: TextStyle(color: Colors.white),
                          ),
                          color: Colors.green,
                          onPressed: () {
                            try {
                              if (running == false)
                                setState(() {
                                  running = true;
                                });
                            } on Exception {}
                          },
                        ),
                        RaisedButton(
                          child: Text(
                            'Stop',
                            style: TextStyle(color: Colors.white),
                          ),
                          color: Colors.red,
                          onPressed: () {
                            if (running == true)
                              setState(() {
                                running = false;
                              });
                          },
                        )
                      ],
                    )
                  ],
                ),
              ),
            );
          }
        }

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

About

A flutter widget to show timer.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 100.0%