Skip to content
pubscout

neat_periodic_task

2.0.1, released 4 years ago by google.dev

Auxiliary classes for reliably running periodic tasks in long-running processes.

WASM-readyQuiet but busy
$ flutter pub add neat_periodic_task
Source repository

What it does

Provides a framework to run periodic maintenance tasks on a loop with a long delay in background processes like a web server. It handles limits on run-times, retries failed executions, catches exceptions, and can optionally prevent concurrent tasks using storage services.

AI-written summary of version 2.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to run background maintenance operations inside a long-running Dart process like a web server
  • You want to limit task run-time, retry failed executions, and log periodic task statuses reliably

Skip it when

  • You are running client-side Flutter UI applications without long-running background server processes
  • You need complex out-of-band cloud scheduling managed entirely outside of your application codebase

Strengths

  • Retries failed task executions automatically after a timeout
  • Limits maximum run-time to prevent hanging loops
  • Catches and logs all exceptions and errors from tasks

Weaknesses

  • Relies on the application process staying alive continuously
  • Lacks built-in cloud cron UI configuration out of the box

Setup

Kind
Pure Dart
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
6

Not documented

import 'dart:io';
import 'package:neat_periodic_task/neat_periodic_task.dart';

void main() async {
  final scheduler = NeatPeriodicTaskScheduler(
    interval: Duration(seconds: 30),
    name: 'hello-world',
    timeout: Duration(seconds: 5),
    task: () async => print('Hello World'),
    minCycle: Duration(seconds: 5),
  );

  scheduler.start();
  await ProcessSignal.sigterm.watch().first;
  await scheduler.stop();
}

Works with

Packages commonly used together with neat_periodic_task: ones it builds on, ones built on it, and its own family.