jumpTo method

void jumpTo({
  1. required int index,
  2. double alignment = 0,
  3. double offset = 0,
  4. TargetRectResolver? targetRectResolver,
})

Places the leading edge of the item at index at alignment of the viewport plus offset pixels, before the next paint.

alignment is a fraction of the viewport's main axis: 0 is the leading edge (the top of a vertical list, the bottom when reversed), 0.5 the center, 1 the trailing edge. Values outside 0..1 are allowed. The resulting position is clamped to the scroll range, so the last items cannot be moved to the top of the viewport. targetRectResolver מיישר אזור בתוך הפריט; האינדקס שהוא מקבל הוא אינדקס פריט גם ברשימה מופרדת. עצם אספקתו מבטלת הוספת ריפוד לפריט 0, גם כשהוא מחזיר null, כך ש-offset נשאר היסט מדויק מהתצוגה.

Implementation

void jumpTo({
  required int index,
  double alignment = 0,
  double offset = 0,
  TargetRectResolver? targetRectResolver,
}) {
  assert(isAttached, "ItemScrollController is not attached.");
  unawaited(
    jumpToAsync(
      index: index,
      alignment: alignment,
      offset: offset,
      targetRectResolver: targetRectResolver,
    ),
  );
}