@@ -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