From ee21121a63612d915463dd49578579c941190ff2 Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Tue, 23 Nov 2021 13:37:46 +0100 Subject: [PATCH] fix: Workaround for null boolean deviceKeysList.outdated is not nullable but we have seen this error in production: `Failed assertion: boolean expression must not be null` So this could either be a null safety bug in Dart or a result of using unsound null safety. The extra equal check `== true` should safe us here --- lib/src/client.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index 75b0e220..0a0aa79b 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1813,7 +1813,13 @@ class Client extends MatrixApi { final deviceKeysList = _userDeviceKeys[userId] ??= DeviceKeysList(userId, this); final failure = _keyQueryFailures[userId.domain]; - if (deviceKeysList.outdated && + + // deviceKeysList.outdated is not nullable but we have seen this error + // in production: `Failed assertion: boolean expression must not be null` + // So this could either be a null safety bug in Dart or a result of + // using unsound null safety. The extra equal check `!= false` should + // save us here. + if (deviceKeysList.outdated != false && (failure == null || DateTime.now() .subtract(Duration(minutes: 5))