Commit 4de2e11a authored by Wilko Manger's avatar Wilko Manger

Add extensions for Lists and Maps with Changes

parent 09e22c2c
......@@ -125,5 +125,18 @@ class Edited<T> extends Change<T> {
String toString() => '$runtimeType($previousValue -> $value)';
extension ChangeMapExtension<K, V> on Map<K, Change<V>> {
bool get hasChanges => this.entries.any((e) => e.value is! Unchanged);
Map<K, Change<V>> get changes =>
Map.fromEntries(this.entries.where((e) => e.value is! Unchanged));
extension ChangeListExtension<K, V> on List<Change<V>> {
bool get hasChanges => this.any((c) => c is! Unchanged);
List<Change<V>> get changes => this.where((c) => c is! Unchanged);
/// @internal
bool hasStateKey(dynamic json) => json.containsKey('state_key');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment