diff --git a/app/lib/widget/viewer.dart b/app/lib/widget/viewer.dart index 5d2d2989..36d3fb67 100644 --- a/app/lib/widget/viewer.dart +++ b/app/lib/widget/viewer.dart @@ -483,13 +483,19 @@ class _ViewerState extends State /// Called when the page is being built for the first time void _onCreateNewPage(BuildContext context, int index) { _pageStates[index] = _PageState(ScrollController( - initialScrollOffset: _isShowDetailPane && !_isClosingDetailPane - ? _calcDetailPaneOpenedScrollPosition(index) - : 0)); + initialScrollOffset: _isShowDetailPane && !_isClosingDetailPane + ? _calcDetailPaneOpenedScrollPosition(index) + : 0, + )); } /// Called when the page is being built after previously moved out of view void _onRecreatePageAfterMovedOut(BuildContext context, int index) { + _pageStates[index]!.setScrollController(ScrollController( + initialScrollOffset: _isShowDetailPane && !_isClosingDetailPane + ? _calcDetailPaneOpenedScrollPosition(index) + : 0, + )); if (_isShowDetailPane && !_isClosingDetailPane) { WidgetsBinding.instance.addPostFrameCallback((_) { if (_pageStates[index]!.itemHeight != null) { @@ -762,6 +768,10 @@ class _ViewerState extends State class _PageState { _PageState(this.scrollController); + void setScrollController(ScrollController c) { + scrollController = c; + } + ScrollController scrollController; double? itemHeight; bool hasLoaded = false;