AppFlowy-IO / appflowy-editor

A highly customizable rich-text editor for Flutter. The AppFlowy Editor project for AppFlowy and beyond.
https://pub.dev/packages/appflowy_editor
Other
448 stars 188 forks source link

[Bug] Document.blank().first or last throw exception IterableElementError.noElement(); #884

Closed Linij closed 2 weeks ago

Linij commented 3 weeks ago

Bug Description

Related file path: lib/src/core/document/document.dart

Error code at line(78 - 87):

 /// First node of the document.
Node? get first => root.children.first;

/// Last node of the document.
Node? get last {
  var last = root.children.last;
  while (last.children.isNotEmpty) {
    last = last.children.last;
  }
  return last;
}

How to Reproduce

just run code Document.blank().first or Document.blank().last while see.

Expected Behavior

throw exception IterableElementError.noElement();

Operating System

macos

AppFlowy Editor Version(s)

3.2.0

Screenshots

image

Additional Context

No response