Skip to content

Commit fe02fd8

Browse files
committed
Load Api on Canvas #2
- Fix variable copyWith issue with runtime variables.
1 parent 480500a commit fe02fd8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lib/src/api/models/variables_model.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,29 @@ class PredefinedVariableData extends VariableData {
361361
class RuntimeVariableData extends VariableData {
362362
/// Creates a new [PredefinedVariableData].
363363
RuntimeVariableData({
364+
String? id,
364365
required super.name,
365366
super.value = '',
366367
super.type = VariableType.text,
367-
}) : super(id: generateId());
368+
}) : super(id: id ?? generateId());
369+
370+
@override
371+
RuntimeVariableData copyWith({
372+
String? id,
373+
String? name,
374+
Object? value,
375+
VariableType? type,
376+
bool? isUsed,
377+
Set<String>? nodes,
378+
}) {
379+
final String? sanitizedValue = value == null
380+
? null
381+
: sanitizeValueForVariableType(value, type ?? this.type);
382+
return RuntimeVariableData(
383+
id: id ?? this.id,
384+
name: name ?? this.name,
385+
value: sanitizedValue ?? this.value,
386+
type: type ?? this.type,
387+
);
388+
}
368389
}

0 commit comments

Comments
 (0)