norns 0.1.2 copy "norns: ^0.1.2" to clipboard
norns: ^0.1.2 copied to clipboard

discontinued
outdated

A Framwork for Interval Timer. Run multiple timers sequentially! easy to use, customizable, and with no common time-related bugs.

Norns

A Framework for Interval Timer

🚧 Alpha version - Use with care. 🚧

Norns [ˈnornez̠]

  1. Goddesses in Norse mythology responsible for shaping the course of human destinies.
  2. A Framework for Interval Timer that will make your time-management easier.

Features #

  • ⏰➞⏰➞⏰➞⏰ Run multiple timers sequentially.
  • Customizable. You can set business-specific actions on timers.
  • Easy to use. Don't worry about common bugs caused when dealing with time! Just describe your business logic to Norns.

Installing #

dependencies:
  norns:
    git: 'https://github.com/sylfree/norns'
import 'package:norns/norns.dart';

A simple Pomodoro Console App #

final norns = Norns();
final timerMetadata = {1: 'Pomodoro', 2: 'Break Time'};
final pointMetadata = {1: 'elpased'};
final perOneSeconds = [pointPeriodic(key: 1, point: 1.s, period: 1.s)];

norns.addAllTimers([
  timer(key: 1, duration: 5.s, points: perOneSeconds),
  timer(key: 2, duration: 2.s, points: perOneSeconds),
]);
norns.setOnPoint((running, point) {
  final pointType = point.type.toShortString();
  final timerName = timerMetadata[running.key]?.padRight(10) ?? '';
  final pointName = pointMetadata[point.key] ?? '';
  final elpased = '${point.point - running.startedAt}'.substring(0, 7);

  print('[$timerName] [$pointType] $elpased $pointName');
});
norns.resume();
[Pomodoro  ] [Timer Start] 0:00:00 
[Pomodoro  ] [Point] 0:00:01 elpased
[Pomodoro  ] [Point] 0:00:02 elpased
[Pomodoro  ] [Point] 0:00:03 elpased
[Pomodoro  ] [Point] 0:00:04 elpased
[Pomodoro  ] [Point] 0:00:05 elpased
[Pomodoro  ] [Timer End] 0:00:05 
[Break Time] [Timer Start] 0:00:00 
[Break Time] [Point] 0:00:01 elpased
[Break Time] [Point] 0:00:02 elpased
[Break Time] [Timer End] 0:00:02

Usage #

  • addTimer and addAllTimers add timers to Norns
  • resume starts Norns
  • pause stop Norns
  • reset initialize Norns
  • breakCurrentRunningTimer skip the current running timer.
  • setOnFire sets the onFire callback.
  • setOnTimerChange sets the onTimerChange callback.
  • setOnFinished sets the onFinished callback.
  • removeOnFire removes the onFire callback
  • removeOnTimerChange removes the onTimerChange callback.
  • removeOnFinished removes the onFinished callback.

Norns Lifecycle

  • onFire

    Called when the first startup.

  • onTimerChange

    Called when timers change.

  • onFinished

    Called when all timers finished.

  • onPoint

    Called when:

    • a timer starts

    • a timer ends

    • a timer broken(skipped)

    • a time-point you set reached. you can set custom time-points with:

    • point

      The example below represents that a timer has a duration of 10 seconds and custom time-points of 5 seconds and 7 seconds.

      timer(
        duration: 10.s,
        points: [
          point(point: 5.s),
          point(point: 7.s)
        ],
      );
      

      and you can receive the events as follows.

      norns.setOnPoint((runningTimer, point) {
        if (point.isTimerStart) {
          // do something when a timer starts
        } 
        if (point.isTimerEnd) {
          // do something when a timer ends
        }
        if (point.isTimerBroken) {
          // do something when a timer broken(skipped)
        }
        if (point.isPoint) {
          // user-defined actions here
        }
      });
      
    • pointFromEnd

      Maybe you want to set an action like 1 seconds left. The example below represents that a timer has a duration of 10 seconds and the custom time-point 9 seconds.

      timer(
        duration: 10.s,
        points: [
          pointFromEnd(point: 1.s),
        ],
      );
      
    • pointPeriodic

      Sets time-points executed periodically.

      timer(
        duration: 10.s,
        points: [
          pointPeriodic(point: 1.s, period: 1.s),
        ],
      );
      
1
likes
140
points
2
downloads

Publisher

unverified uploader

Weekly Downloads

A Framwork for Interval Timer. Run multiple timers sequentially! easy to use, customizable, and with no common time-related bugs.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

collection

More

Packages that depend on norns