Skip to content

Commit 72f13ed

Browse files
SaadArdatiBirjuVachhani
authored andcommitted
AI Prompts Progress
1 parent b4dc63e commit 72f13ed

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/src/api/custom_component.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ class ComponentData with EquatableMixin, SerializableMixin {
114114
required this.nodes,
115115
this.variables = const {},
116116
this.conditions = const {},
117-
}) : assert(nodes.isNotEmpty),
118-
assert(width > 0 && height > 0);
117+
}) : assert(width > 0 && height > 0);
119118

120119
@override
121120
List<Object?> get props => [width, height, nodes, variables, conditions];

lib/src/api/models/node_box.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ class NodeBox with EquatableMixin, DynamicSerializableMixin {
197197

198198
/// Creates a new [NodeBox] from a [json] Map.
199199
factory NodeBox.fromJson(dynamic json) {
200+
if (json == null || (json is List && json.isEmpty) || (json is Map && json.isEmpty)) {
201+
return NodeBox(0, 0, 0, 0);
202+
}
200203
if (json case [num x, num y, num width, num height]) {
201204
return NodeBox(
202205
x.toDouble(),
@@ -436,6 +439,10 @@ class OuterNodeBox extends NodeBox {
436439

437440
/// Creates an [OuterNodeBox] from a json map.
438441
factory OuterNodeBox.fromJson(dynamic json) {
442+
if (json == null || (json is List && json.isEmpty) || (json is Map && json.isEmpty)) {
443+
return OuterNodeBox(0, 0, 0, 0, edgeInsets: EdgeInsetsModel.zero);
444+
}
445+
439446
final box = NodeBox.fromJson(json);
440447
return OuterNodeBox(
441448
box.x,
@@ -666,6 +673,10 @@ class InnerNodeBox extends NodeBox {
666673

667674
/// Creates an [InnerNodeBox] from a JSON map.
668675
factory InnerNodeBox.fromJson(dynamic json) {
676+
if (json == null || (json is List && json.isEmpty) || (json is Map && json.isEmpty)) {
677+
return InnerNodeBox(0, 0, 0, 0, edgeInsets: EdgeInsetsModel.zero);
678+
}
679+
669680
final box = NodeBox.fromJson(json);
670681
return InnerNodeBox(
671682
box.x,
@@ -738,6 +749,10 @@ class RotatedNodeBox extends NodeBox {
738749

739750
/// Creates a [RotatedNodeBox] from a JSON map.
740751
factory RotatedNodeBox.fromJson(dynamic json) {
752+
if (json == null || (json is List && json.isEmpty) || (json is Map && json.isEmpty)) {
753+
return RotatedNodeBox(0, 0, 0, 0, rotationDegrees: 0);
754+
}
755+
741756
final box = NodeBox.fromJson(json);
742757
return RotatedNodeBox(
743758
box.x,

0 commit comments

Comments
 (0)