1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-26 10:50:29 +02:00

Fixes local position late initialization (#2884)

This commit is contained in:
martyfuhry 2023-06-20 20:58:17 -04:00 committed by GitHub
parent 6baeca654b
commit 26f58d3335
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,7 +52,7 @@ class GalleryViewerPage extends HookConsumerWidget {
final showAppBar = useState<bool>(true); final showAppBar = useState<bool>(true);
final isPlayingMotionVideo = useState(false); final isPlayingMotionVideo = useState(false);
final isPlayingVideo = useState(false); final isPlayingVideo = useState(false);
late Offset localPosition; Offset? localPosition;
final authToken = 'Bearer ${Store.get(StoreKey.accessToken)}'; final authToken = 'Bearer ${Store.get(StoreKey.accessToken)}';
final currentIndex = useState(initialIndex); final currentIndex = useState(initialIndex);
final currentAsset = loadAsset(currentIndex.value); final currentAsset = loadAsset(currentIndex.value);
@ -246,8 +246,13 @@ class GalleryViewerPage extends HookConsumerWidget {
return; return;
} }
// Guard [localPosition] null
if (localPosition == null) {
return;
}
// Check for delta from initial down point // Check for delta from initial down point
final d = details.localPosition - localPosition; final d = details.localPosition - localPosition!;
// If the magnitude of the dx swipe is large, we probably didn't mean to go down // If the magnitude of the dx swipe is large, we probably didn't mean to go down
if (d.dx.abs() > dxThreshold) { if (d.dx.abs() > dxThreshold) {
return; return;