moveCursorToFirstFragment function

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

Moves cursor to the start (offset 0) of the first fragment child of container. Handles Link transparency.

Implementation

void moveCursorToFirstFragment(Cursor cursor, InlineContainerNode container) {
  final children = container.getChildren();
  if (children.isEmpty) return;
  final first = children.first;
  if (first is Link && first.fragments.isNotEmpty) {
    cursor.moveTo((first.fragments.first as Fragment).id, 0);
  } else if (first is Fragment) {
    cursor.moveTo(first.id, 0);
  }
}