efficient_circular_countdown_timer 0.0.2

SDKflutter
Platformandroidioswindowslinuxmacosweb

A highly efficient, customizable, and accessible circular countdown timer widget for Flutter. Designed for minimal CPU/memory usage.

EfficientCircularCountdownTimer

A highly efficient, customizable, and accessible circular countdown timer widget for Flutter. Designed for minimal CPU/memory usage and maximum flexibility.

Features

  • Circular countdown and count-up modes
  • Highly customizable appearance (colors, gradients, stroke, text)
  • Controller for start, pause, resume, reset, and more
  • Callbacks for start, complete, and value changes
  • Optimized for performance and accessibility (low CPU usage)

Demo

Demo

Getting Started

Add this package to your pubspec.yaml:

dependencies:
  efficient_circular_countdown_timer: ^0.0.1

Import and use in your widget tree:

import 'package:efficient_circular_countdown_timer/efficient_circular_countdown_timer.dart';

final controller = CountdownController();

EfficientCircularCountdownTimer(
  duration: 10,
  controller: controller,
  width: 100,
  height: 100,
  fillColor: Colors.green,
  ringColor: Colors.grey[300],
  backgroundColor: Colors.white,
  strokeWidth: 8.0,
  textStyle: TextStyle(fontSize: 24, color: Colors.black),
  isReverse: true,
  isReverseAnimation: false,
  autoStart: true,
  onStart: () => print('Started!'),
  onComplete: () => print('Done!'),
  onChange: (value) => print('Time: $value'),
)

API Reference

Widget Properties

PropertyTypeDescription
durationintTotal duration in seconds
initialDurationintInitial value in seconds (default: 0)
isReverseboolCount down if true, up if false
autoStartboolStart automatically (default: true)
width, heightdoubleSize of the timer
fillColorColor?Progress arc color
ringColorColor?Background ring color
backgroundColorColor?Circle background color
fillGradientGradient?Progress arc gradient (overrides fillColor)
ringGradientGradient?Ring gradient (overrides ringColor)
backgroundGradientGradient?Background gradient (overrides backgroundColor)
strokeWidthdoubleThickness of rings
strokeCapStrokeCapArc end style
isReverseAnimationboolReverse arc animation direction
isTimerTextShownboolShow timer text (default: true)
textStyleTextStyle?Timer text style
textAlignTextAlign?Timer text alignment
timeFormatterString Function(int)?Custom time formatter
controllerCountdownController?Programmatic control
onStartVoidCallback?Called when timer starts
onCompleteVoidCallback?Called when timer completes
onChangeValueChanged?Called when timer value changes

Controller Usage

final controller = CountdownController();
controller.start();
controller.pause();
controller.resume();
controller.reset();
controller.restart();

Example

See the example directory for a full demo and advanced usage, including custom formatting and controller integration.

Performance

  • Designed to update only once per second for minimal CPU usage (~2% on typical devices).
  • Uses RepaintBoundary and paint/shader caching for efficient rendering.
  • Efficient update strategy: Instead of using a continuous animation, the timer only triggers a UI update when the timer value changes (typically once per second). This eliminates unnecessary repaints and keeps CPU usage extremely low, even for long-running timers.

License

See LICENSE.