This kind of check is best done as an assert. Asserts are development time checking and help you find issues, but are removed from release builds by the compiler. This way you can have a ton of asserts and not worry about your app running slowly, but still ensure behavior is correct. In this case, it's a misuse of this dialog to pass it in with it.done()==true, and if you assert it at development time it'll help you find the cases where that may happen.