`@immutable` Classes Should Only Have `const` Constructors
Define constructors for `@immutable` classes as `const` to ensure that instances are created efficiently and cannot be modified.
performance-efficiencystack-flutter+1
High
Add dispose methods to prevent memory leaks
Dispose controllers, focus nodes, animations, timers, and cancel subscriptions in `dispose()`.
stack-flutterui-robustness
High
Add error handling to app initialization
Guard app startup with zone-level handlers and FlutterError hooks; surface fatal errors and report them.
error-handlingobservability-logging+1
High
Avoid swallowing exceptions by returning null
Do not silently catch and return null on errors; log context and either rethrow or return a typed failure/Result.
error-handlingstack-flutter
High
Avoid Unnecessary `toList()` with Spread Operator
Remove unnecessary calls to `.toList()` when using the spread operator (`...`) as it is already designed to work with iterable collections.
duplication-complexityperformance-efficiency+1
High
Avoid Unnecessary `toList()` with Spread Operator
Remove unnecessary `.toList()` calls when using the spread operator (`...`) to avoid redundant operations.
duplication-complexityperformance-efficiency+1
High
Avoid Using `!` to Null Check Nullable Type Parameters
Do not use `!` to check nullable type parameters, as this can lead to runtime exceptions if the type itself is nullable.
error-handlingstack-flutter
High
Avoid Using Constant Patterns with Type Literals
Do not use constant patterns with type literals as it can lead to unexpected behavior. Prefer direct type checking instead.
error-handlingstack-flutter+1
High
Check `mounted` Before Using `BuildContext` After an Async Operation
Verify if a widget is still mounted before using `BuildContext` inside an asynchronous operation to prevent accessing invalid states.
error-handlingstack-flutter+1
High
Do Not Assign Values to `void` Variables
Avoid assigning values to `void` variables as `void` is not a compatible type and doing so results in runtime errors.
error-handlingstack-flutter+1
High
Prefer `for` Elements Over `Map.fromIterable`
Use `for` elements inside map literals instead of `Map.fromIterable` to improve readability and allow better compiler optimizations.
performance-efficiencyreadability-refactor+1
High
Prefer `is!` Over `!is` for Type Checks
Use `is!` instead of `!is` for type checking to prevent confusion and ensure consistent behavior.
readability-refactorstack-flutter+1
High
Prefer `SizedBox` Over `Container` for Spacing
Use `SizedBox` instead of `Container` when adding spacing in layouts to improve performance and avoid unnecessary rendering overhead.
performance-efficiencystack-flutter
High
Use `const` for Literal Constructor Parameters in `@immutable` Classes
Ensure that all literal values passed to constructors of `@immutable` classes are marked as `const` to prevent unnecessary object creation.
performance-efficiencystack-flutter+1
High
Use rethrow to preserve stack traces
When re-emitting a caught exception, use `rethrow` instead of `throw e` to keep the original stack trace.
error-handlingstack-flutter
High
Use Web-Only Libraries Only in Flutter Web Plugins
Ensure `dart:html`, `dart:js`, and `dart:js_util` are only used in Flutter web plugins to prevent runtime errors in non-web environments.
module-architecturestack-flutter
High
Wrap Uri.parse in try-catch blocks
Use try/catch (or Uri.tryParse with validation) around Uri.parse to guard against FormatException and invalid inputs.
error-handlingstack-flutter
Low
Add const modifiers for better performance
Mark compile-time constants and constant widgets with `const` to reduce rebuild cost and GC pressure.
performance-efficiencystack-flutter
Low
AVOID defining a class that contains only static members
Ensure that classes with only static members are converted to top-level functions or extensions. Avoid unnecessary class instantiation.
maintainabilitymodule-architecture+1
Low
AVOID redundancy with the surrounding context
Check if the method, variable, or class title contains redundant context (e.g., using 'carDrive()' when 'drive()' would suffice). Ensure the title is concise and avoids repetition of surrounding context.
duplication-complexityreadability-refactor+2
Low
Capture and print stack traces in catch blocks
Use `catch (e, stack)` and log both exception and stack; do not log message-only.
error-handlingobservability-logging+1
Low
Centralize analytics tracking logic
Route all analytics events through a single service/helper instead of calling the SDK directly from widgets and blocs.
duplication-complexitymaintainability+2
Low
Define dialog handlers once to avoid duplication
For confirm/cancel flows, define common callbacks (confirm/cancel) once and reuse across dialogs.
duplication-complexitystack-flutter+1
Low
Define reusable constants for repeated values
Create theme-like constants (radii, gaps, durations) and reuse across widgets.