Closed stephane-archer closed 2 months ago
A possible gap in the rule! I think this doesn't come up because it is more idiomatic to write if (!context.mounted)
.
Actually I cannot reproduce this at HEAD. Can you say what version of Dart/Flutter you are using, and provide a more full example (just the full function body there should be sufficient).
Oops, apologies. I can reproduce. :D
@srawlins no worries The idiomatic way would fail silently or need an else close to handle the error which is quite verbose I'm not sure why it's the idiomatic way :)
if (context.mounted == false) {
throw "I don't fail silently!";
}
ScaffoldMessenger.of(context).showSnackBar(snackBar);
Hmm, I might have not been clear. I mean that the idiomatic way to write context.mounted == false
is !context.mounted
.
@srawlins ho I see, I misunderstood what you meant, sorry.
I hope to allow context.mounted == false
would be easy to add.
@srawlins you are the best 🤯
ok but:
Don't use 'BuildContext's across async gaps. Try rewriting the code to not use the 'BuildContext', or guard the use with a 'mounted' check.