Why this matters
Reduces copy-paste mistakes and ensures consistent analytics/logging on actions.
For confirm/cancel flows, define common callbacks (confirm/cancel) once and reuse across dialogs.
Reduces copy-paste mistakes and ensures consistent analytics/logging on actions.
Side-by-side examples engineers can pattern-match during review.
TextButton(onPressed: () { log('cancel'); Navigator.pop(context); })
TextButton(onPressed: () { log('cancel'); Navigator.pop(context); })void onCancel(BuildContext c) { logger.info('dialog_cancel'); Navigator.pop(c); }
TextButton(onPressed: () => onCancel(context), child: const Text('Cancel'))inline Cancel handlers everywhereshared onCancel/onConfirm helpersFrom the same buckets as this rule.