check messagePagination nullability

This commit is contained in:
Salvatore Giordano
2021-02-01 09:55:53 +01:00
parent e03f50ae5a
commit 0d4db87906
@@ -112,7 +112,7 @@ class MessageDao extends DatabaseAccessor<MoorChatDatabase>
.map(_messageFromJoinRow)
.get());
if (messagePagination.lessThan != null) {
if (messagePagination?.lessThan != null) {
final lessThanIndex = msgList.indexWhere(
(m) => m.id == messagePagination.lessThan,
);
@@ -120,7 +120,7 @@ class MessageDao extends DatabaseAccessor<MoorChatDatabase>
msgList.removeRange(lessThanIndex, msgList.length);
}
}
if (messagePagination.greaterThanOrEqual != null) {
if (messagePagination?.greaterThanOrEqual != null) {
final greaterThanIndex = msgList.indexWhere(
(m) => m.id == messagePagination.greaterThanOrEqual,
);
@@ -128,7 +128,7 @@ class MessageDao extends DatabaseAccessor<MoorChatDatabase>
msgList.removeRange(0, greaterThanIndex);
}
}
if (messagePagination.limit != null) {
if (messagePagination?.limit != null) {
return msgList.take(messagePagination.limit).toList();
}
return msgList;