From 44c348256d3f4e151cf1ba2ba65bd8321e15df76 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Mon, 9 Jan 2023 16:19:48 +0530 Subject: [PATCH] Handle error in label text builder --- lib/ui/viewer/gallery/gallery.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ui/viewer/gallery/gallery.dart b/lib/ui/viewer/gallery/gallery.dart index 540e7ccb7..2af302085 100644 --- a/lib/ui/viewer/gallery/gallery.dart +++ b/lib/ui/viewer/gallery/gallery.dart @@ -258,11 +258,16 @@ class _GalleryState extends State { return gallery; }, labelTextBuilder: (int index) { - return getMonthAndYear( - DateTime.fromMicrosecondsSinceEpoch( - _collatedFiles[index][0].creationTime!, - ), - ); + try { + return getMonthAndYear( + DateTime.fromMicrosecondsSinceEpoch( + _collatedFiles[index][0].creationTime!, + ), + ); + } catch (e) { + _logger.severe("label text builder failed", e); + return ""; + } }, thumbBackgroundColor: Theme.of(context).colorScheme.galleryThumbBackgroundColor,