prefer_const_declarations
Forces the use of const whenever possible.
ย ๐ง Example: const myValue = 10;
ย ๐ก Improves performance, especially during widget build.
avoid_unnecessary_containers
Avoids using Container when it's not doing anything.
ย ๐ง Replace it with Padding, SizedBox, DecoratedBox, etc.
ย ๐ก Reduces widget tree complexity.
avoid_print
Avoid using print() in production code.
ย ๐ง Use Logger, debugPrint, or proper logging tools.
ย ๐ก Makes log control and maintenance easier.
prefer_single_quotes
Prefers single quotes (') over double quotes (").
ย ๐ง Promotes code consistency.
ย ๐ก Follows the standard of most Dart/Flutter packages.
always_declare_return_types
Enforces declaring return types for functions.
ย ๐ง Example: String getTitle() {ย ... }
ย ๐ก Improves readability and prevents potential errors.
unnecessary_const
Avoids using const where it's redundant (like inside another const).
ย ๐ง Dart infers it automatically in many cases.
ย ๐ก Keeps your code cleaner and more concise.
no_literal_bool_comparisons
Avoids comparisons like if (isValid == true) or == false.
ย ๐ง Instead, use if (isValid) or if (!isValid).
ย ๐ก Makes your code more direct and idiomatic.
use_key_in_widget_constructors
Ensures you add a Key to your custom widgets.
ย ๐ง Helps control widget rebuilds in the widget tree.
ย ๐ก Prevents subtle bugs and improves performance.
unnecessary_lambdas
Avoids using lambdas when you can pass the function directly.
ย ๐ง Instead of onPressed: () => doSomething(), use onPressed: doSomething.
ย ๐ก Results in cleaner and more readable code.
unnecessary_getters_setters
Avoids get and set methods that do nothing but return or assign a variable.
ย ๐ง Access the field directly when there's no added logic.
ย ๐ก Simplifies code and avoids unnecessary abstractions.
By enabling these lints, you're not just following best practicesโ-โyou're also making your Flutter codebase more robust, scalable, and professional. Happy coding! ๐
If this helped you, consider giving it a star or a clap to support the content. It really helps and motivates me to bring more tips like this! ๐๐
Top comments (0)