diffutil_dart
5.0.0, released 6 months ago by littlebat.dev
Calculate the difference between two lists as a list of edit operations.
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.
- baseflow_plugin_template
A template for plugin examples
53Compare - intersperse
Insert a given element between each element of an Iterable or List.
50Compare - age_calculator
Calculate age, date differences, and add time durations in years, months, and days.
48Compare - list_diff
Calculates a minimal list of operations to convert one list into another.
44Compare
Works with
Packages commonly used together with diffutil_dart: ones it builds on, ones built on it, and its own family.
- flutter_chat_uiBuilt on diffutil_dartA customizable, cross‑platform chat UI widget set for Flutter.
- animated_tree_viewBuilt on diffutil_dartA hierarchical tree view widget with animations, based on AnimatedList.
- automatic_animated_listBuilt on diffutil_dartAn AnimatedList that automatically computes item deltas and animates list changes.
- cometchat_chat_uikitBuilt on diffutil_dartPrebuilt UI components for text chat, media messaging, and voice/video calls.
- diffutil_sliverlistBuilt on diffutil_dartA SliverList that implicitly animates changes using diffutil.
- auto_animated_listBuilt on diffutil_dartA ListView widget that automatically animates items when the list changes.