fix: range error when deleting last Memory from FullScreenMemory (#1680)

This commit is contained in:
Vishnu Mohandas 2024-01-26 15:27:03 +05:30 committed by GitHub
commit b904bdbd3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -66,9 +66,14 @@ class _FullScreenMemoryDataUpdaterState
}
void removeCurrentMemory() {
setState(() {
widget.memories.removeAt(indexNotifier.value);
});
widget.memories.removeAt(indexNotifier.value);
if (widget.memories.isNotEmpty) {
setState(() {
if (widget.memories.length == indexNotifier.value) {
indexNotifier.value -= 1;
}
});
}
}
@override