diff --git a/lib/search/word_search/entry_id_query.dart b/lib/search/word_search/entry_id_query.dart index 10c12de..28d58a8 100644 --- a/lib/search/word_search/entry_id_query.dart +++ b/lib/search/word_search/entry_id_query.dart @@ -77,7 +77,7 @@ String _filterFTSSensitiveCharacters(String word) { ${!countOnly ? 'LIMIT ?' : ''} ) - ${countOnly ? 'SELECT COUNT("entryId") AS count' : 'SELECT "entryId", MAX("score") AS "score"'} + SELECT ${countOnly ? 'COUNT("entryId") AS count' : '"entryId", MAX("score") AS "score"'} FROM ( SELECT * FROM fts_results UNION @@ -128,7 +128,7 @@ Future _queryKanjiCount( ); return connection .rawQuery(query, args) - .then((result) => result.first['count'] as int); + .then((result) => result.firstOrNull?['count'] as int? ?? 0); } Future> _queryKana( @@ -161,7 +161,7 @@ Future _queryKanaCount( ); return connection .rawQuery(query, args) - .then((result) => result.first['count'] as int); + .then((result) => result.firstOrNull?['count'] as int? ?? 0); } Future> _queryEnglish(