Search packages, repositories and app categories

Package detailsv0.13.0

circular_buffer

A Dart Circular Buffer container based on List with a fixed capacity.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
90.5K
Likes
7
Pub points
160

Install package

flutter pub add circular_buffer

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Dart implementation of a circular buffer built on top of List with a fixed capacity, designed for efficient insertion and removal of elements in a first-in, first-out (FIFO) manner. It automatically overwrites the oldest element when full, making it ideal for scenarios requiring continuous data streaming or limited memory usage. The package is lightweight and compatible across all major platforms, including mobile, web, and desktop.

Use cases

  • Real-time data processing
  • Audio or sensor data buffering
  • Log rotation with fixed size
  • High-frequency event handling

Key features

  • Fixed-size storage
  • Automatic overflow handling
  • O(1) insertion and removal
  • Platform-agnostic
  • Simple API based on List

Suitable for

  • Performance-critical applications
  • Streaming data pipelines
  • Memory-constrained environments
  • Applications needing FIFO behavior

Considerations

  • Not suitable for large datasets due to fixed capacity
  • No built-in persistence
  • Requires manual management of buffer state
  • Limited to basic operations without advanced features

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

dart-circularbuffer

A circular buffer with a fixed capacity. Supports most List read operations and a fixed-size write interface (add, addHead, clear).

final buffer = CircularBuffer<int>(3)..add(1)..add(2);
print(buffer.length); // 2
print(buffer.first); // 1
print(buffer.isFilled); // false
print(buffer.isUnfilled); // true

buffer.add(3);
print(buffer.length); // 3
print(buffer.isFilled); // true
print(buffer.isUnfilled); // false

buffer.add(4);
print(buffer.first); // 2

buffer.addHead(4);
print(buffer.length); // 3
print(buffer[0]); // 4
print(buffer[1]); // 2
print(buffer[2]); // 3

Categories

Source repository

Projects using this package

No data available yet.