A dart timer that can be configured to fire once or repeatedly with ability start, stop, resume and cancel.

Overview

A timer that can be configured to fire once or repeatedly with ability start, stop, resume and cancel.

Getting started

Add CompleteTimer to your pubspec.yaml file:

dependencies:
  complete_timer: ^1.0.0

Import CompleteTimer in files that it will be used:

import 'package:complete_timer/complete_timer.dart';

How to use?

Create a CompleteTimer and give duration and callback you want to fire after the given duration.

// By default the timer starts automatically.
final CompleteTimer timer = CompleteTimer(
    duration: Duration(seconds: 5),
    // The callback function is invoked after the given duration.
    callback: (timer) {
      print('timer finished');
    },
  );

Params

  final CompleteTimer normalTimer = CompleteTimer(
    // must a non-negative Duration.
    duration: Duration(seconds: 5),
    
    // If periodic sets true
    // The callback is invoked repeatedly with duration intervals until
    // canceled with the cancel function.
    // Defaults to false.
    periodic: false,
    
    // If autoStart sets true timer starts automatically, default to true.
    autoStart: true,
    
    // The callback function is invoked after the given duration.
    callback: (timer) {
      print('normal example');
      timer.stop();
      // We call stop function before getting elapsed time to get a exact time.
      print('normal timer finished after: ${timer.elapsed}');
    },
  );

CompleteTimer methods

  • start()

      Start the timer, you don't need to call it if autoStart sets true.
      If call when the timer already started, then it resume the timer
      which this means elapsed and tick starts increasing from their previous value.
    
  • stop()

      Stop the timer.
      The elapsed and tick stops increasing after this call.
      If call when timer is stopped does nothing.
    
  • cancel()

      Cancel the timer.
      The elapsed and tick resets after this call.
    
  • elapsed

      Elapsed time.
    
  • tick

      The value starts at zero and is incremented each time a timer event
      occurs, so each callback will see a larger value than the previous one.
    
  • isRunning

     Whether the CompleteTimer is currently running.
    
You might also like...

The Integration Test Helper has pre-configured methods that allow for faster test deployment for end to end (e2e) test coverage.

The Integration Test Helper has pre-configured methods that allow for faster test deployment for end to end (e2e) test coverage.

The Integration Test Helper has pre-configured methods that allow for faster test deployment for end to end (e2e) test coverage (using Android and iOS

Apr 7, 2022

A server app built using Shelf, configured to enable running with Docker.

A server app built using Shelf, configured to enable running with Docker.

May 23, 2022

This package give you ability to integrate with Drone API easily in any platform using Dart

This package give you ability to integrate with Drone API easily in any platform using Dart

Drone Dart Dart is a multi client programming language which allow you to compile and run your code on multiple platforms. Because of that we decided

Dec 22, 2022

User auth form - Signup and signin user auth form with ability to stay signed in and have an option to signout.

user_auth_form SIgnup and signin user authentification form Getting Started This project is a starting point for a Flutter application. A few resource

Jan 6, 2022

I start to learn dart-flutter. And also this project was basics of Dart

learning_dart A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Dec 14, 2022

Socket library for creating real-time multiplayer games. Based on TCP, with the ability to send messages over UDP (planned).

Game socket The library was published in early access and is not stable, as it is being developed in parallel with other solutions. English is not a n

Aug 10, 2022

A powerful plugin that fully uses the native image library's ability to display images on the flutter side.

PowerImage A powerful plugin that fully uses the native image library's ability to display images on the flutter side. δΈ­ζ–‡ζ–‡ζ‘£ Features: Supports the abi

Dec 23, 2022

Rolify is an app that allows you to play multiple sounds simultaneously, with the ability to manage audio individually

Rolify is an app that allows you to play multiple sounds simultaneously, with the ability to manage audio individually

Rolify is an app that allows you to play multiple sounds simultaneously, with the ability to manage audio individually. You can also add the music you have on your phone, all completely offline and free.

Sep 30, 2022
Owner
MohammadAminZamani.afshar
I'm a 18 years old boy who love programming and computer world and develop mobile applications with Flutter.
MohammadAminZamani.afshar
Stop Watch - Stop Watch Timer in Flutter

timerapp A new Flutter project. Getting Started This project is a starting point

MD Omar Faruk. 0 Jan 27, 2022
This is Stop Watch Timer for flutter plugin.πŸƒβ€β™‚οΈ

stop_watch_timer Simple CountUp timer / CountDown timer. It easily create app of stopwatch. https://pub.dev/packages/stop_watch_timer Example code See

shohei 75 Nov 9, 2022
Flutter kick start - Flutter Kick Start Project Pattern

Flutter Kick Start Project Pattern A new Flutter project where basically show a

Md. Sabik Alam Rahat 3 Apr 27, 2022
A program for Mac, Windows and Linux to manage multiple translation files at once

A program for Mac, Windows and Linux to manage multiple translation files at once. Easy to use UI, multithreaded for optimization and Google Translate natively integrated. NB: At the moment it doesn't support nested translation keys.

Jesper Paulsen 4 Aug 8, 2022
Build a system that recommends jobs based on resume.

Job Findr Problem Statement: Build a system that recommends jobs based on resume. Problem Description: The problem statement suggests to build a syste

null 2 Jul 8, 2022
FBP Go (Fire Behaviour Prediction on the Go)

FBP Go provides users a mobile solution to perform fire behaviour calculations in the field.

Province of British Columbia 4 Jul 6, 2022
Buildpack dart - A server app built using Shelf, configured to enable running with Docker

Hosted at https://dart-buildpack-demo-ruyjilv5wq-uc.a.run.app/ Buildpack defined

Kevin Moore 12 Dec 15, 2022
A server app built using Shelf, configured to enable running with Docker

A server app built using Shelf, configured to enable running with Docker. This sample code handles HTTP GET requests to / and /echo/<message> Requests

Tornike Gogberashvili 1 Jan 26, 2022
A server app built using Shelf, configured to enable running with Docker

A server app built using Shelf, configured to enable running with Docker. Project Structure Running the sample Running with the Dart SDK You can run t

null 0 Jan 12, 2022