fast_equatable_lint 2.0.0 copy "fast_equatable_lint: ^2.0.0" to clipboard
fast_equatable_lint: ^2.0.0 copied to clipboard

This is a set of rules to make classes using FastEquatable more maintainable. We validate that every fields in an FastEquatable class is linked to the hashParameters getter.

fast_equatable_lint #

Lint rules for classes using fast_equatable. They validate that every instance field of a FastEquatable class is listed in the hashParameters getter.

This is a Dart analyzer plugin. Diagnostics show up in your IDE and on the command line via dart analyze / flutter analyze, and the rules ship with quick fixes.

Originally a fork of equatable_lint, adapted for fast_equatable.

Requirements #

Dart 3.10 (Flutter 3.38) or later, which is when analyzer plugins became supported.

Setup #

Add the plugin to the top-level plugins section of your analysis_options.yaml:

plugins:
  fast_equatable_lint: ^2.0.0

That is the whole setup. Two things worth knowing:

  • No pubspec.yaml entry is needed. The analysis server resolves plugin packages on its own, in a synthetic package separate from your app. Do not add fast_equatable_lint to your dependencies or dev_dependencies.
  • It must go in the root package or workspace analysis_options.yaml. Plugins cannot be enabled or configured in a nested analysis options file. In a monorepo, put it in the file at the workspace root.

After any change to the plugins section, restart the Dart Analysis Server (in VS Code: Dart: Restart Analysis Server). Changes are not picked up otherwise.

Both rules are registered as warnings, so they are enabled by default and need no diagnostics section.

Rules #

missing_field_in_equatable_props #

Reports a non-static instance field of a FastEquatable class that is missing from hashParameters. Static fields and getters are ignored.

class Example with FastEquatable {
  Example({this.field});

  final String? field; // ← reported: not in hashParameters

  @override
  List<Object?> get hashParameters => [];
}

Quick fixes:

  • Add the field to hashParameters
  • Add every missing field to hashParameters
  • Create a hashParameters override containing the field
  • Create a hashParameters override containing every field

always_call_super_props_when_overriding_equatable_props #

Reports a subclass that overrides hashParameters without calling super.hashParameters, which would silently drop the parent's fields from equality.

class Child extends Base {
  Child({this.newField});

  final String? newField;

  @override
  List<Object?> get hashParameters => [newField]; // ← reported: drops Base's fields
}

Quick fix: rewrite the getter as super.hashParameters..addAll([...]).

Suppressing diagnostics #

Plugin diagnostics are suppressed with the plugin name as a prefix:

// ignore: fast_equatable_lint/missing_field_in_equatable_props

// ignore_for_file: fast_equatable_lint/missing_field_in_equatable_props

CI #

No extra step is required. dart analyze and flutter analyze run analyzer plugins and fail on their diagnostics, so your existing analyze step covers these rules.

If a plugin fails to load, dart analyze reports it explicitly before any diagnostics ("An error occurred while executing an analyzer plugin"), so a broken plugin will not pass silently.

Local development #

To test a local checkout against a project, point the plugin at its path:

plugins:
  fast_equatable_lint:
    path: ../fast_equatable_lint

Restart the analysis server to pick up source changes; a path plugin is not rebuilt automatically while the server is running. If you suspect a stale build, remove the plugin cache with rm -rf ~/.dartServer/.plugin_manager and let it regenerate.

The example/ directory is wired up this way. Run cd example && dart pub get && dart analyze to exercise the rules.

1
likes
150
points
163
downloads

Documentation

API reference

Publisher

verified publisherfabi.online

Weekly Downloads

This is a set of rules to make classes using FastEquatable more maintainable. We validate that every fields in an FastEquatable class is linked to the hashParameters getter.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

analysis_server_plugin, analyzer, analyzer_plugin, collection, fast_equatable

More

Packages that depend on fast_equatable_lint