Skip to content
pubscout

list_diff

2.0.1, released 5 years ago by an unverified publisher

Calculates a minimal list of operations to convert one list into another.

$ flutter pub add list_diff
Source repository

What it does

The package offers a diff method that compares two lists and returns a list of insertions and deletions needed to transform the first list into the second. It includes extension methods to apply these operations directly and can automatically run calculations in a separate isolate for large datasets.

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 compute the minimal difference between two lists of items.
  • You are updating collections in animated lists or tracking list mutations.

Skip it when

  • You require high-performance processing for massive datasets where an O(N*M) runtime is unacceptable.
  • You are looking for a state-management framework.

Strengths

  • Provides both asynchronous and synchronous diff calculation methods.
  • Automatically spawns an isolate for large datasets by default.
  • Allows custom equality and hash code functions.

Weaknesses

  • Runtime complexity is currently O(N*M).
  • Limited to insertions and deletions (no direct move/replacement operations mentioned).

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
var operations = await diff(
  ['coconut', 'nut', 'peanut'],
  ['kiwi', 'coconut', 'maracuja', 'nut', 'banana'],
);
operations.forEach(print);

Alternatives

Packages that do the same job and could replace list_diff.

  • diffutil_dart

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

  • hex

    Provides simple HEX.encode and HEX.decode functions for converting between byte lists and hexadecimal strings.

  • string_to_color

    Convert strings to colors, hex strings, or hex integers in Dart and Flutter.

  • moving_average

    Calculate simple, weighted, and exponential moving averages for lists of numbers or objects.

Works with

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