From 28d3d3e679d0cb0bc33c2bfd6d206114f0a80986 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 17 Aug 2023 23:50:41 -0500 Subject: [PATCH] fix(mobile): invalid range on label builder crash timeline (#3759) * fix(mobile): invalid date on label builder crash timeline * actual fix --------- Co-authored-by: Alex Tran --- .../home/ui/asset_grid/immich_asset_grid_view.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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, );