I have a GlobalKey
set on an item in my listview, which I automatically scroll to using ensurevisible
await _scrollController!.position.ensureVisible(
_scrollToThisKey.currentContext!.findRenderObject()!,
alignment: 0.0,
duration: const Duration(milliseconds: 500),
curve: Curves.linear
);
Using alignment
, I can select what % is shown, for example 0.0 means the very top of my widget is at the top of the screen, and 1.0 means the bottom of the widget is visible at the bottom of the screen.
However, I need more granular control of the offset, specifically I want it to scroll to a position -100 pixels from the top of the widget. SO that the position -100px above the widget would be at the top of my screen.
Is there a way to give an offset to this?