Skip to content

Commit fded259

Browse files
chrisbobbegnprice
authored andcommitted
autocomplete: Remove a probably-wrong null assertion
I've been waffling on this and haven't managed to convince myself that the "!" was correct.
1 parent 58181da commit fded259

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/widgets/autocomplete.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,12 @@ class ComposeAutocomplete extends AutocompleteField<ComposeAutocompleteQuery, Co
202202
if (query is! MentionAutocompleteQuery) {
203203
return; // Shrug; similar to `intent == null` case above.
204204
}
205-
final user = store.getUser(userId)!; // must exist because UserMentionAutocompleteResult
205+
final user = store.getUser(userId);
206+
if (user == null) {
207+
// Don't crash on theoretical race between async results-filtering
208+
// and losing data for the user.
209+
return;
210+
}
206211
// TODO(i18n) language-appropriate space character; check active keyboard?
207212
// (maybe handle centrally in `controller`)
208213
replacementString = '${userMention(user, silent: query.silent, users: store)} ';

0 commit comments

Comments
 (0)