Search packages, repositories and app categories

GitHub repositoryaryzhov/flutter-timer-builder

flutter-timer-builder

A Flutter widget that rebuilds itself on scheduled, periodic, or dynamically generated time events.

flutter-timer-builder project cover
Stars
38
Forks
10
Last push (UTC)
Jul 30, 2022
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

TimerBuilder

A widget that rebuilds itself on scheduled, periodic, or dynamically generated time events.

Here are some use cases for this widget:

  • When showing time since or until a specified event;
  • When the model updates frequently but you want to limit UI update frequency;
  • When showing current date or time;
  • When the representation a widget depends on a certain time event.

animated image

Examples

Periodic rebuild
import 'package:timer_builder/timer_builder.dart';

class ClockWidget extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return TimerBuilder.periodic(Duration(seconds: 1),
      builder: (context) {
        return Text("${DateTime.now()}");
      }
    );
  }
  
}
Rebuild on a schedule
import 'package:timer_builder/timer_builder.dart';

class StatusIndicator extends StatelessWidget {

  final DateTime startTime;
  final DateTime endTime;
  
  StatusIndicator(this.startTime, this.endTime);
  
  @override
  Widget build(BuildContext context) {
    return TimerBuilder.scheduled([startTime, endTime],
      builder: (context) {
        final now = DateTime.now();
        final started = now.compareTo(startTime) >= 0;
        final ended = now.compareTo(endTime) >= 0;
        return Text(started ? ended ? "Ended": "Started": "Not Started");
      }
    );
  }
  
}

Alex Ryzhov GitHub avatar
GitHub author

Alex Ryzhov ↗

I am making contributions to this project in my personal capacity. I am not conveying any rights to any intellectual property of any third parties.

Los Gatos, California, USAOfficial website ↗
LanguagesDart

Packages published by this repository

Dependencies used

Dependency list 2 items

  • flutter{"sdk":"flutter"}
  • flutter_testDevelopment{"sdk":"flutter"}

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗