From a26c24928e795b7eaa7a6d201bc6a76895fe5bca Mon Sep 17 00:00:00 2001 From: Xun Gong Date: Mon, 24 May 2021 00:53:26 -0700 Subject: [PATCH] fix optional --- lib/src/models/documents/nodes/node.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/models/documents/nodes/node.dart b/lib/src/models/documents/nodes/node.dart index 6bb0fb97..08335727 100644 --- a/lib/src/models/documents/nodes/node.dart +++ b/lib/src/models/documents/nodes/node.dart @@ -53,6 +53,9 @@ abstract class Node extends LinkedListEntry { /// Offset in characters of this node in the document. int get documentOffset { + if (parent == null) { + return offset; + } final parentOffset = (parent is! Root) ? parent!.documentOffset : 0; return parentOffset + offset; }