Adds `doc.isEmpty` check to `Document._loadDocument(Delta doc)` (#163)

pull/180/head
Guilherme C. Matuella 4 years ago committed by GitHub
parent 3e576aeb9a
commit 60127aeb04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      lib/models/documents/document.dart

@ -223,7 +223,12 @@ class Document {
String toPlainText() => _root.children.map((e) => e.toPlainText()).join();
void _loadDocument(Delta doc) {
if (doc.isEmpty) {
throw ArgumentError.value(doc, 'Document Delta cannot be empty.');
}
assert((doc.last.data as String).endsWith('\n'));
var offset = 0;
for (final op in doc.toList()) {
if (!op.isInsert) {

Loading…
Cancel
Save