equatable_lint_ultimate


This package is based on a fork from the equatable_lint package

This package used the custom_lint package


Table of content

Setup local

  • In your pubspec.yaml, add these dev_dependencies :
dev_dependencies:
  custom_lint:
  equatable_lint_ultimate:
  • In your analysis_options.yaml, add this plugin :
analyzer:
  plugins:
    - custom_lint

# Optional : Disable unwanted rules
custom_lint:
  rules:
    - always_call_super_props_when_overriding_equatable_props: false
  • Run flutter pub get or dart pub get in your package

  • Possibly restart your IDE

Setup CI

flutter analyze or dart analyze don't use this custom rule when checking your code

If you want to analyze your code with this rule in your CI, add a step that run flutter pub run custom_lint or dart run custom_lint

All the lints

missing_field_in_equatable_props

Class extending Equatable should put every field into equatable props

Good:

class MyClass extends Equatable {
  const MyClass({this.myField});
  final String? myField;
  @override
  List<Object?> get props => [myField];
}

Bad:

class MyClass extends Equatable {
  const MyClass({this.myField});
  final String? myField;
  @override
  List<Object?> get props => [];
}

always_call_super_props_when_overriding_equatable_props

Should always call super when overriding equatable props

Good:

class MyClass extends RandomClassExtendingEquatable {
  const MyClass({this.newField});
  final String? newField;
  @override
  List<Object?> get props => super.props..addAll([newField]);
}

Bad:

class MyClass extends RandomClassExtendingEquatable {
  const MyClass({this.newField});
  final String? newField;
  @override
  List<Object?> get props => [newField];
}

All the lints fixes

missing_field_in_equatable_props fixes

Add every fields to equatable props

Add every fields to equatable props sample

Add field to equatable props

Add field to equatable props sample

always_call_super_props_when_overriding_equatable_props fixes

Call super in overridden equatable props

Call super in overridden equatable props sample

All the assists

Make class extend Equatable

Make class extend Equatable sample

About Tomasz Czajka

I am deeply committed to ensuring code quality, which is why I have chosen to adopt these wonderful package (as their original authors are no longer reachable).