`@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.
duplication-complexitymaintainability+2
Low
Do Not Use Block Comments for Documentation
Use `///` for documentation instead of block comments to improve tooling support and ensure better formatting in generated docs.
docs-adrsstack-flutter+1
Low
DO title extensions using UpperCamelCase
Ensure that extensions use UpperCamelCase naming conventions (e.g., `MyExtension`). Avoid other casing styles that could reduce readability.
stack-flutterstyle-conventions
Low
DO title import prefixes using lowercase_with_underscores
Check that import prefixes use lowercase_with_underscores (e.g., `my_library`), following Dart's style guide.
stack-flutterstyle-conventions
Low
DO title other identifiers using lowerCamelCase
Ensure that identifiers such as variables and method titles are written in lowerCamelCase (e.g., `myVariable`). Avoid using other naming conventions.
stack-flutterstyle-conventions
Low
DO type annotate fields and top-level variables if the type isn't obvious
Check that fields and top-level variables are type-annotated explicitly when the type is not obvious from the context. This avoids ambiguity.
readability-refactorstack-flutter+1
Low
DON'T explicitly title libraries
Ensure that libraries are not explicitly titled. Dart provides automatic library titles, so avoid redundant naming of libraries in the code.
duplication-complexitystack-flutter+1
Low
DON'T make the parameter to == nullable
Ensure that parameters to `==` are non-nullable. Avoid using nullable parameters as they can introduce unexpected behavior and null reference errors.
error-handlingstack-flutter+1
Low
Extract complex conditional logic to separate methods
Move long/branchy UI decisions into named predicates or mappers to keep build methods simple.
readability-refactorstack-flutter
Low
Extract duplicated widget logic to reusable methods
Factor identical widget trees or builders into private helpers or dedicated widgets.
duplication-complexityreadability-refactor+1
Low
Extract magic numbers to named constants
Replace raw numeric/string literals used for dimensions, durations, and thresholds with named constants.
maintainabilityreadability-refactor+2
Low
Handle StateError from firstWhere operations
Always provide `orElse` to firstWhere (or use a safe helper) when the match may not exist.
error-handlingstack-flutter
Low
PREFER a noun phrase for a non-boolean property or variable
Ensure that non-boolean properties or variables are titled with noun phrases (e.g., `userDetails`, not `getUserDetails`). This improves readability.
readability-refactorstack-flutter+1
Low
PREFER using _, __, etc. for unused callback parameters
Check for functions with unused parameters and ensure they are titled with `_` or `__` to indicate they are intentionally unused.
maintainabilityreadability-refactor+1
Low
Refactor duplicated dialog action logic
Centralize repeated dialog creation/action handlers into a helper to ensure consistent UX and error handling.
duplication-complexityerror-handling+2
Low
Remove redundant null-assertion operators
Avoid `!` when nullability is already proven or a safer alternative (`??`, early return) exists.
readability-refactorstack-flutter+1
Low
Use `///` Doc Comments for Members and Types
Use `///` instead of regular comments to properly document Dart classes, methods, and properties for automatic documentation generation.
docs-adrsstack-flutter+1
Low
Use `const` Instead of `static final` Where Possible
Replace `static final` with `const` where applicable to enable compile-time evaluation and optimize performance.
performance-efficiencystack-flutter+1
Low
Use localized strings instead of hardcoded text
Read UI strings from a localization source (e.g., AppLocalizations, arb) rather than hardcoding.