avoid-mutable-equatable-subclass-fields
- Group
- Correctness
- Path
lint/correctness/avoid-mutable-equatable-subclass-fields- Default
- On (recommended)
- Origin
- Falcon
- Domain
- equatable
- Rule
- 93 of 512
Flags mutable instance fields on subclasses inheriting Equatable equality.
Changing value-object state can invalidate hash-based collection membership. This checks
declared fields, including private, late and primary-constructor fields, only when the
resolved inherited equality implementation belongs to package:equatable Equatable or
EquatableMixin. Static, final, abstract and external fields, interface-only implementations,
unresolved inheritance and classes replacing equality themselves are excluded.
Invalid
import 'package:equatable/equatable.dart';
import 'package:equatable/equatable.dart' as eq;
import 'support.dart';
class Direct extends Equatable {
int value = 1;
List<Object?> get props => [value];
}
class MixedValue with EquatableMixin {
int value = 1;
List<Object?> get props => [value];
}
class Indirect extends Middle {
int child = 1;
}
class Prefixed extends eq.Equatable {
late int value;
List<Object?> get props => [value];
}
class Private extends Mixed {
int _value = 1;
}class Direct extends Equatable { int value = 1;class MixedValue with EquatableMixin { int value = 1;class Indirect extends Middle { int child = 1;class Prefixed extends eq.Equatable { late int value;class Private extends Mixed { int _value = 1;Valid
import 'package:equatable/equatable.dart';
import 'support.dart';
class Immutable extends Equatable {
final int value = 1;
List<Object?> get props => [value];
}
class Static extends Parent { static int value = 1; }
class LateFinal extends Middle { late final int value; }
class Constants extends Mixed { static const int value = 1; }
class GetterOnly extends Parent { int get value => 1; }
class OwnEquality extends Parent {
int value = 1;
bool operator ==(Object other) => identical(this, other);
int get hashCode => 0;
}
class Unrelated { int value = 1; }
class InterfaceOnly implements Equatable {
int value = 1;
List<Object?> get props => [value];
}Configure avoid-mutable-equatable-subclass-fields
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"correctness": {
"avoid-mutable-equatable-subclass-fields": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/correctness/avoid-mutable-equatable-subclass-fields: <reason>More correctness rules
- avoid-mutable-global-variables
avoid_mutable_global_variablesDisallow mutable top-level variables.
- avoid-nested-futures
Avoid
Future<Future<T>>,FutureOr<Future<T>>, and other directly nested future wrappers. - avoid-nested-streams-and-futures
Avoid directly nesting SDK streams and futures:
Stream<Future<T>>andFuture<Stream<T>>complicate consumption. - avoid-read-inside-buildrecommendedprovider
Flags non-listening Provider reads directly inside Flutter widget builds.
- avoid-recursive-calls
Reports direct self-calls in functions and methods, including guarded recursion.
- avoid-recursive-widget-callsrecommendedflutter
Warns when a widget's build method constructs the same widget again.
- avoid-ref-inside-state-disposeriverpod
Rejects Riverpod widget references used during State.dispose.
- avoid-ref-read-inside-buildrecommendedriverpod
Flags one-time Riverpod reads of provider state during widget build.