{
  "id": 5861643,
  "title": "Scrolling to an Index in a Flutter Lazy List, Without Building Everything Above It",
  "url": "https://urgent.news/2026/09/05/scrolling-to-an-index-in-a-flutter-lazy-list-without-building",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-05T23:22:11.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/devshakib/scrolling-to-an-index-in-a-flutter-lazy-list-without-building-everything-above-it-7o9"
  },
  "original_language": "en",
  "account": "The article discusses the problem of jumping to a specific index in a Flutter lazy list without building all the preceding elements, which is a common challenge when dealing with large lists. The author highlights the limitations of various methods that people often attempt to solve this issue, such as using a fixed item extent, estimating average row height, using GlobalKey to ensure visibility, or rebuilding the entire list with the desired anchor index. The article explains that these approaches either fail to provide a smooth jumping experience or are not practical for real-world scenarios.\n\nThe core solution proposed in the article is to use an AnchoredListController in combination with an AnchoredList widget. This approach involves splitting the list into two parts at the anchor index, with the content before the anchor laid out in reverse order and the anchor itself serving as the center of the viewport. By setting the scroll offset to zero, the anchor index becomes the reference point for scrolling, allowing the user to jump to any index with O(1) complexity and without the need to rebuild or measure anything above the anchor. This method also addresses the issue of content shifting when new items are added above the current position, as items above the anchor are naturally positioned at negative offsets, ensuring the user's content remains stable.\n\nThe key takeaway from the article is that Flutter's center property of Viewport, which supports negative offsets, can be leveraged to create a solution for jumping to arbitrary indices in a lazy list. By understanding that the offset origin can be placed anywhere, developers can implement a simple and efficient solution that avoids the pitfalls of previous workarounds. The article also mentions the added benefit of handling dynamic content, such as chat feeds or logs, where new items can arrive above the current position without disrupting the user's experience.",
  "summary": "You have a list of a million rows and you want to jump to row 842,013. ScrollController.jumpTo takes a pixel offset, not an index. To convert one to the other you need the total height of the 842,012 rows above your target — and a lazy list has never built them, so it does not know how tall they are. That is not an oversight. It is the entire point of a lazy list. Flutter ships no answer. The two…",
  "key_points": [
    "Proposes AnchoredListController and AnchoredList widget solution",
    "Splits list at anchor index, lays out content before anchor reversed",
    "Sets scroll offset to zero for O(1) jumping with stable content"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}