'Lint don't override field in flutter

I'm new in using Lint and I'm getting a blue underline on my UserModel variables with a message of Don't override fields and Annotate overridden members. I'm having a hard time understanding the Good and Bad rules in the example docs. I still get the same message after adding @override.

class UserModel extends UserEntity {
  final int id;
  final String? uid;
 
  const UserModel(
      {required this.id,
      this.uid})
      : super(
          id: id,
          uid: uid,
        );
}


//

class UserEntity extends Equatable {
  const UserEntity({
    required this.id,
    this.uid,
    this.provider,
   });

  final int id;
  final String? uid;
 
  static const empty = UserEntity(id: 0, uid: '');

  @override
  List<Object> get props => [id];
}


Solution 1:[1]

The fields id and uid already are defined within the UserEntity class so it is redundant to declare them again as fields in the UserModel class.

class UserModel extends UserEntity {
  const UserModel({required int id, String? uid}) : super(id: id, uid: uid);
}

EDIT: as of dart 2.17 you can simplify the above code by using super initializers.

class UserModel extends UserEntity {
  const UserModel({required super.id, super.uid});
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1