Why this matters
Improves readability and testability of control flow.
Move long/branchy UI decisions into named predicates or mappers to keep build methods simple.
Improves readability and testability of control flow.
Side-by-side examples engineers can pattern-match during review.
if (a && (b || c) && user.role == 'admin' && now.isAfter(deadline)) ...if (shouldShowAdminWarning(user, now)) ...
bool shouldShowAdminWarning(User u, DateTime now) => a && (b || c) && u.isAdmin && now.isAfter(deadline);deep nested ifs in build()bool predicate(...) => ...; // used in build()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.