Skip to content

Commit

Permalink
add a hack for lists in the LazyMergedMapView
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 committed Oct 24, 2024
1 parent 0af4bd1 commit 9234261
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkgs/dart_model/lib/src/lazy_merged_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ class LazyMergedMapView extends MapBase<String, Object?> {
rightValue is Map<String, Object?>) {
return LazyMergedMapView(leftValue, rightValue);
}
if (leftValue != rightValue) {
if (leftValue is List<Object?> && rightValue is List<Object?>) {
if (leftValue.length != rightValue.length) {
throw StateError('Cannot merge lists of different lengths, '
'got $leftValue and $rightValue');
}
// TODO: Something better for lists, it isn't clear how to merge them.
return leftValue;
} else if (leftValue != rightValue) {
throw StateError('Cannot merge maps with different values, and '
'$leftValue != $rightValue');
}
Expand Down

0 comments on commit 9234261

Please sign in to comment.