Make the isRunningOnBot getter more robust. (#14811)

It was failing in the case of an AppContext being in scope
but not having a `BotDetector` seeded in it.
This commit is contained in:
Todd Volkert 2018-02-21 15:01:46 -08:00 committed by GitHub
parent 1bdbfe7b52
commit 37ffb2d730
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,10 +45,8 @@ class BotDetector {
}
bool get isRunningOnBot {
if (context == null) {
return _kBotDetector.isRunningOnBot;
}
return context[BotDetector].isRunningOnBot;
final BotDetector botDetector = context?.getVariable(BotDetector) ?? _kBotDetector;
return botDetector.isRunningOnBot;
}
String hex(List<int> bytes) {