hexa studios

Sharing the Progress Bar Countdown Timer

Sharing the Progress Bar Countdown Timer

Behind the Scenes, Developing the Progress Bar Countdown Timer Flutter Package

At Hexa Studios, we've used packages and open source software wherever possible. Recently, I had the opportunity to work on a new Flutter package that I'm excited to share: Progress Bar Countdown. This package creates an animated linear countdown timer that mimics the style of a progress bar — perfect for apps needing a visual timer interface.

The Idea Behind Progress Bar Countdown

The idea originated from an app concept I'm working on, but the applications of this widget are varied. Whether it’s a timed quiz, task timer, or countdown to an event, the goal was to provide a fully customizable and easy-to-integrate solution. While there are many countdown timers available, the combination of a progress bar animation and countdown text adds an extra level of clarity and user engagement.

Key Features

As I built out the package, I focused on creating a feature set that would make the countdown adaptable to different use cases:

Here’s an example GIF of the Progress Bar Countdown in action:

Example Countdown Timer

Development Process

During the development phase, I focused on making the API simple and developer-friendly. Here’s a brief look at some of the parameters and their impact:

Challenge: Smoothing Out Animations

One of the trickier parts of development was ensuring that the animations remained smooth across different devices and screen sizes. The solution came down to optimizing Flutter’s built-in AnimationController and testing across various conditions to reduce stuttering, especially when changing the progress direction or pausing and resuming the countdown.

Example Usage

Here’s a quick code snippet that shows just how easy it is to implement:

ProgressBarCountdown(
  initialDuration: 60,
  progressColor: Colors.blue,
  progressBackgroundColor: Colors.grey[300]!,
  initialTextColor: Colors.black,
  revealedTextColor: Colors.white,
  height: 40,
  textStyle: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
  countdownDirection: ProgressBarCountdownAlignment.left,
  controller: ProgressBarCountdownController(),
  autoStart: false,
  onStart: () => { debugPrint("Countdown Started") },
  onComplete: () => { debugPrint("Countdown Completed") },
  onChange: (changeValue) => { debugPrint("Change Value: $changeValue") },
  timeFormatter: (Duration remainingTime) {
    final minutes = remainingTime.inMinutes
        .remainder(60)
        .toString()
        .padLeft(2, '0');
    final seconds = remainingTime.inSeconds
        .remainder(60)
        .toString()
        .padLeft(2, '0');
    final milliseconds = (remainingTime.inMilliseconds % 1000 ~/ 10)
        .toString()
        .padLeft(2, '0');
    return '$minutes:$seconds:$milliseconds';
  },
)

Try It Out

You can find the package on pub.dev, FlutterGems (a great source for finding unique and open source plugins) or check out the full source code on GitHub.

LinkURL
Flutterhttps://pub.dev/packages/progress_bar_countdown
GitHubhttps://github.com/Hexa-Studios/progress_bar_countdown
Hexa DocsHexa Studios Docs
Flutter GemsFlutter Gems

If you’re looking for an easy way to add animated timers to your Flutter app, give Progress Bar Countdown a try and let me know what you think!


Other Recent Posts

Background Image for Blog

Seo Árainn Mhór AI Goes Live

The Seo Árainn Mhór community app gets its own AI assistant today - a beta launch that lets people interact with the island's first AI-powered guide.

New Post!
Background Image for Blog

Experimenting with AI

I wanted to share my latest experimentation AI: MCP servers, AI SDK, and various tooling before landing on Mastra as the tech stack for building AI agents across the Hexa products.

hexa studios

mobile app and web developers

All rights reserved.