flutter_heyteacher_timer_workflow 2.1.0+144 copy "flutter_heyteacher_timer_workflow: ^2.1.0+144" to clipboard
flutter_heyteacher_timer_workflow: ^2.1.0+144 copied to clipboard

The flutter heyteacher package for manage timer workflow, that means tasks with an execution duration prefixed

Flutter Heyteacher Timer Workflow #

This package provides functionalities to manage timer-based workflows for the Heyteacher project.

Features #

This package exports the following modules via timer_workflow.dart:

  • Workflow Management:
    • TimerWorkflow: The core class for managing the lifecycle of a timer workflow.
    • WorkflowStatus: Defines the current state of the workflow.
  • Tasks:
    • TimerTask: Represents a specific task definition within the workflow.
    • RunningTask: Represents an active instance of a task.
  • Localization: FlutterHeyteacherTimerWorkflowLocalizations provides localized strings for workflow-related UI.
  • Error Handling:
    • WorkflowTaskAlreadyInitialized
    • WorkflowTaskNotInitialized

The action available on a workflow are:

  • start(): start the workflow
  • stop(): stop the workflow
  • pause(): pause the workflow
  • restart(): restart the workflow
  • next(): go to the next task

The stream of the workflow is a [Stream<RunningTask

  • workflowName: the name of the workflow
  • status: the current status of the workflow
  • current: the current task
  • next: the next task
  • changed: if the task has just changed
  • taskElapsedTime: the elapsed time of the current task
  • totalElapsedTime: the total elapsed time of completed tasks

Usage #

Define your workflow by extending TimerWorkflow<T>:

class MyWorkflow extends TimerWorkflow<MyTask> {
  @override
  String get name => 'My Workflow';

  @override
  void initializeTasks() => tasks.addAll([
    MyTask(
      name: 'Task 1',
      description: 'First Task',
      duration: const Duration(seconds: 10),
    ),
    MyTask(
      name: 'Task 2',
      description: 'Second Task',
      duration: const Duration(seconds: 20),
    ),
    MyTask(
      name: 'Task 3',
      description: 'Third Task',
      duration: const Duration(seconds: 15),
    ),
  ]);
}

Define your task by extending TimerTask:

class MyTask extends TimerTask {
  const MyTask({
    required super.name,
    required super.description,
    required super.duration,
  });
}

Start the workflow:

_workflow.start();

Listen to the workflow changes:

_workflow.stream.listen((runningTask) {
  if (runningTask.changed) {
    print('Task ${runningTask.current?.name} completed');
    if (runningTask.next != null) {
      print('Task ${runningTask.next?.name} started');
    } else {
      print('All done');
    }
  }
});

A complete app example can be found in example

0
likes
160
points
15
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

The flutter heyteacher package for manage timer workflow, that means tasks with an execution duration prefixed

Repository
View/report issues

Topics

#flutter #timer #workflow #timer-workflow

Funding

Consider supporting this project:

liberapay.com

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_heyteacher_locale, flutter_heyteacher_platform, flutter_heyteacher_views, flutter_localizations, intl

More

Packages that depend on flutter_heyteacher_timer_workflow