Skip to content
pubscout

diffutil_dart

5.0.0, released 6 months ago by littlebat.dev

Calculate the difference between two lists as a list of edit operations.

WASM-ready
$ flutter pub add diffutil_dart
Source repository

What it does

Calculates the difference (edit script) between two lists using the Myers diff algorithm. It returns operations like insert, remove, change, and move to transform one list into another.

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

Use it when

  • You need to animate the insertion, removal, or reordering of items in a list without managing a StatefulWidget
  • You receive a whole new list of data from an endpoint and need to compute the delta updates

Skip it when

  • You are using a state management framework that already handles list diffing internally
  • You only need simple list comparison without granular edit operations

Strengths

  • Efficient Myers algorithm implementation with O(N) space and O(N + D^2) time performance
  • Supports custom equality checks, move detection, and batching of insert/remove operations
  • Provides updates with concrete data items via getUpdatesWithData()

Weaknesses

  • Move detection increases time complexity to O(N^2)
  • Requires manual application of the returned edit operations to your UI or data structures

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
final diffResult = calculateListDiff<int>([1, 2, 3], [1, 3, 4]);
for (final update in diffResult.getUpdates()) {
  update.when(
    insert: (pos, count) => print("inserted $count on $pos"),
    remove: (pos, count) => print("removed $count on $pos"),
    change: (pos, payload) => print("changed on $pos with payload $payload"),
    move: (from, to) => print("move $from to $to"),
  );
}

Alternatives

Packages that do the same job and could replace diffutil_dart.

Works with

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