Skip to content
pubscout

bit_array

2.3.0, released 2 years ago by agilord.com

Compactly stores bits in an array data structure

WASM-ready
$ flutter pub add bit_array
Source repository

What it does

A bit array implementation (also known as BitMap, BitSet, BitString, or BitVector) that allows you to compactly store and manipulate bits in Dart. It supports logical operations like AND, OR, XOR, range updates, and querying set bits.

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

Use it when

  • You need to store large collections of boolean flags with minimal memory overhead.
  • You are implementing algorithms that rely on bitwise operations or bitsets.

Skip it when

  • You just need a standard List<bool> and memory footprint is not a concern.

Strengths

  • Compact memory storage for bits
  • Supports common bitwise operators (&, |, ^)
  • Provides range and callback-driven updates

Weaknesses

  • Limited to basic bit array manipulation functionality

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:bit_array/bit_array.dart';

void main() {
  final array = BitArray(1024);
  array[12] = true;
  array.setBit(123);
  array.invertBit(200);
  array.clearBit(12);
  print(array.asIntIterable().toList()); // prints [123, 200]
}

Alternatives

Packages that do the same job and could replace bit_array.

  • tuple

    Provides immutable tuple classes for grouping values.

  • collection

    Utility functions and classes that extend Dart's collection types and algorithms.

  • typed_data

    Utility functions and classes for easier work with dart:typed_data lists.

  • kdtree

    A fast Dart implementation of the k-dimensional (k-d) tree data structure.