many_lints 0.1.2
many_lints: ^0.1.2 copied to clipboard
A useful collection of custom lints for Flutter & Dart projects
A useful collection of custom lints for Flutter & Dart projects. Uses the new analysis_server_plugin system for direct integration with dart analyze and IDEs.
Features #
This package provides a set of custom lints to help you write better Flutter code.
Getting started #
Requires Dart 3.10+ (Flutter 3.38+)
Add many_lints to the top-level plugins section in your analysis_options.yaml file (NOT under analyzer:):
plugins:
many_lints: ^0.1.2
That's it — the analysis server will automatically download and resolve the plugin from pub.dev. There is no need to add it to your pubspec.yaml.
Local development #
For local development or when using many_lints from a cloned repository, use the path option:
git clone https://github.com/Nikoro/many_lints.git /path/to/many_lints
plugins:
many_lints:
path: /path/to/many_lints
Note: Git dependencies are not directly supported by the plugin system. Clone the repository locally and use the
pathoption instead.
Important: After any change to the
pluginssection, you must restart the Dart Analysis Server.
Configuring diagnostics #
All rules are registered as warnings and enabled by default. You can enable or disable individual rules under the diagnostics key:
plugins:
many_lints:
diagnostics:
prefer_center_over_align: true
use_bloc_suffix: false
Available Lints #
All lints are enabled by default as warnings.
- avoid_single_child_in_multi_child_widgets: Avoid using a single child in widgets that can accept multiple children (e.g.,
Row,Column,Flex). - avoid_unnecessary_consumer_widgets: Ensures that a
ConsumerWidgetuses therefparameter. - avoid_unnecessary_hook_widgets: Ensures that a
HookWidgetuses hooks. - prefer_align_over_container: Enforces the use of
AlignoverContainerwith only the alignment parameter. - prefer_any_or_every: Prefer
.any()or.every()over.where().isEmpty/.isNotEmpty. - prefer_center_over_align: Prefer
CenteroverAlignwithalignment: Alignment.center. - prefer_padding_over_container: Enforces the use of
PaddingoverContainerwith only margin. - use_bloc_suffix: Enforces the use of the
Blocsuffix for classes that extendBloc. - use_cubit_suffix: Enforces the use of the
Cubitsuffix for classes that extendCubit. - use_dedicated_media_query_methods: Enforces the use of dedicated
MediaQuerymethods instead ofMediaQuery.of(context). - use_notifier_suffix: Enforces the use of the
Notifiersuffix for classes that extendNotifier.
Quick fixes #
The following rules include auto-fixable quick fixes:
prefer_center_over_alignprefer_align_over_containerprefer_padding_over_containerprefer_any_or_everyavoid_unnecessary_hook_widgetsuse_dedicated_media_query_methods
Available Assists #
- Convert to collection-for: Converts
.map().toList()or.map().toSet()to collection-for syntax.
Suppressing Diagnostics #
To suppress a specific lint, use comments:
// ignore: many_lints/prefer_center_over_align
const Align(...);
// ignore_for_file: many_lints/use_bloc_suffix
Example #
use_cubit_suffix #
DO use Cubit suffix for your cubit names.
❌ BAD:
class MyClass extends Cubit<bool> {}
✅ GOOD:
class MyClassCubit extends Cubit<bool> {}
