From 9234261afe58dbfe8b1e0c6b9c2947e7e183cd22 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Thu, 24 Oct 2024 21:05:55 +0000 Subject: [PATCH] add a hack for lists in the LazyMergedMapView --- pkgs/dart_model/lib/src/lazy_merged_map.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/dart_model/lib/src/lazy_merged_map.dart b/pkgs/dart_model/lib/src/lazy_merged_map.dart index 7e92f081..4e1815c3 100644 --- a/pkgs/dart_model/lib/src/lazy_merged_map.dart +++ b/pkgs/dart_model/lib/src/lazy_merged_map.dart @@ -39,7 +39,14 @@ class LazyMergedMapView extends MapBase { rightValue is Map) { return LazyMergedMapView(leftValue, rightValue); } - if (leftValue != rightValue) { + if (leftValue is List && rightValue is List) { + 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'); }