Query doesn't work when there is no data

I want to get the latest model based on createdAt field and I am querying like this:

QuizPath? getLatestQuizPath() {
return _realm
.query(‘TRUEPREDICATE SORT(createdAt DESC)’)

I would expect this to return null when there is no data but the app freezes when I call this and there is no data. When I first add data and then quey, it works. What could be the problem?