diff --git a/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid_view.dart b/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid_view.dart index 1ad7f3a28f..d00734f2c3 100644 --- a/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid_view.dart +++ b/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid_view.dart @@ -300,7 +300,13 @@ class ImmichAssetGridViewState extends State { } Text _labelBuilder(int pos) { - final date = widget.renderList.elements[pos].date; + final maxLength = widget.renderList.elements.length; + if (pos < 0 || pos >= maxLength) { + return const Text(""); + } + + final date = widget.renderList.elements[pos % maxLength].date; + return Text( DateFormat.yMMMM().format(date), style: const TextStyle( @@ -335,7 +341,8 @@ class ImmichAssetGridViewState extends State { itemBuilder: _itemBuilder, itemPositionsListener: _itemPositionsListener, itemScrollController: _itemScrollController, - itemCount: widget.renderList.elements.length + (widget.topWidget != null ? 1 : 0), + itemCount: widget.renderList.elements.length + + (widget.topWidget != null ? 1 : 0), addRepaintBoundaries: true, );