Why this matters
Prevents white-screen crashes and centralizes crash logging from the very first frame.
Guard app startup with zone-level handlers and FlutterError hooks; surface fatal errors and report them.
Prevents white-screen crashes and centralizes crash logging from the very first frame.
Side-by-side examples engineers can pattern-match during review.
void main() { runApp(App()); }void main() {
WidgetsFlutterBinding.ensureInitialized();
FlutterError.onError = (details) {
logger.severe('Flutter error', details.exception, details.stack);
};
runZonedGuarded(() => runApp(const App()), (e, st) {
logger.severe('Uncaught zone error', e, st);
});
}runApp(App()) // no global handlersrunZonedGuarded(() => runApp(App()), onError)From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.