moveCursorToLastFragment function

void moveCursorToLastFragment(
  1. Cursor cursor,
  2. InlineContainerNode container
)

Moves cursor to the end (text.length) of the last fragment child of container. Handles Link transparency.

Implementation

void moveCursorToLastFragment(Cursor cursor, InlineContainerNode container) {
  final children = container.getChildren();
  if (children.isEmpty) return;
  final last = children.last;
  if (last is Link && last.fragments.isNotEmpty) {
    final f = last.fragments.last as Fragment;
    cursor.moveTo(f.id, f.text.length);
  } else if (last is Fragment) {
    cursor.moveTo(last.id, last.text.length);
  }
}