@@ -529,6 +529,43 @@ class FunctionsRepository {
529
529
newValue = jsonEncode (currentValue);
530
530
}
531
531
532
+ if (action.variable.type.isMap &&
533
+ action.mapOperation != MapOperation .replace) {
534
+ // Get current value of the map variable.
535
+ final Map ? currentValue =
536
+ variableNotifier.value.getValue ().typedValue <Map >();
537
+ // If map variable does not exist, return false.
538
+ if (currentValue == null ) return false ;
539
+ // Retrieve all variables.
540
+ final Iterable <VariableData > variables =
541
+ codelesslyContext.variables.values.map ((e) => e.value);
542
+ // Find the value of variable referenced by key.
543
+ final keyVariableValue = PropertyValueDelegate .retrieveVariableValue (
544
+ action.key,
545
+ variables,
546
+ codelesslyContext.data,
547
+ IndexedItemProvider .of (context),
548
+ );
549
+ // If key is a variable, use its value. Else, use the key as it is.
550
+ final String key =
551
+ keyVariableValue is String ? keyVariableValue : action.key;
552
+ // Perform map operations.
553
+ switch (action.mapOperation) {
554
+ case MapOperation .add:
555
+ currentValue.addAll (newValue.toMap () ?? {});
556
+ break ;
557
+ case MapOperation .remove:
558
+ currentValue.remove (key);
559
+ break ;
560
+ case MapOperation .update:
561
+ currentValue[key] = newValue;
562
+ break ;
563
+ default :
564
+ break ;
565
+ }
566
+ newValue = jsonEncode (currentValue);
567
+ }
568
+
532
569
final VariableData updatedVariable =
533
570
variableNotifier.value.copyWith (value: newValue);
534
571
0 commit comments