Skip to content

Commit 480500a

Browse files
committed
Load Api on Canvas #1
- Implement api retrieval for a canvas and embed into variables system. - Implement api calling in SDK and api variables creation from LayoutBuilder.
1 parent ec59dbf commit 480500a

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

lib/src/api/models/trigger.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ enum TriggerType {
4343
pointerDown,
4444

4545
/// Triggered when a pointer up event is received on the target.
46-
pointerUp;
46+
pointerUp,
47+
48+
/// Triggered when the widget (specifically canvas) is loaded.
49+
onLoad;
4750

4851
/// Displayable string representation of the trigger type.
4952
String get prettify {
@@ -70,6 +73,8 @@ enum TriggerType {
7073
return 'Editing Complete';
7174
case TriggerType.submitted:
7275
return 'Submitted';
76+
case TriggerType.onLoad:
77+
return 'On Load';
7378
}
7479
}
7580
}

lib/src/api/models/trigger.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/variables_model.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class VariableData
106106
VariableData({
107107
required this.id,
108108
required this.name,
109-
String value = '',
109+
Object? value = '',
110110
this.type = VariableType.text,
111111
}) : value = sanitizeValueForVariableType(value, type).toString();
112112

@@ -356,3 +356,13 @@ class PredefinedVariableData extends VariableData {
356356
super.type = VariableType.text,
357357
}) : super(id: generateId());
358358
}
359+
360+
/// A variable class that represents variables that are created at runtime.
361+
class RuntimeVariableData extends VariableData {
362+
/// Creates a new [PredefinedVariableData].
363+
RuntimeVariableData({
364+
required super.name,
365+
super.value = '',
366+
super.type = VariableType.text,
367+
}) : super(id: generateId());
368+
}

lib/src/api/nodes/canvas_node.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CanvasNode extends ParentNode
4141
bool get isAScaffold => properties.isAScaffold;
4242

4343
@override
44-
List<TriggerType> get triggerTypes => [TriggerType.click];
44+
List<TriggerType> get triggerTypes => [TriggerType.onLoad];
4545

4646
@override
4747
List<ReactionMixin> get reactiveChildren =>

0 commit comments

Comments
 (0)