felangel / equatable

A Dart package that helps to implement value based equality without needing to explicitly override == and hashCode.
https://pub.dev/packages/equatable
MIT License
920 stars 102 forks source link

Fix NPE on toString with null prop #156

Closed giljulio closed 1 year ago

giljulio commented 1 year ago

Status

READY

Breaking Changes

NO

Description

When a property is null and toString is invoked, a NPE is throw

felangel commented 1 year ago

Hi @giljulio 👋 Thanks for opening an issue!

Can you please provide a minimal reproduction sample?

import 'package:equatable/equatable.dart';

class Person extends Equatable {
  const Person(this.name);

  final String? name;

  @override
  List<Object?> get props => [name];

  @override
  bool? get stringify => true;
}

void main() {
  final unknown = Person(null);
  print(unknown.toString()); // Person(null)
}
felangel commented 1 year ago

Closing for now as I'm unable to reproduce.

giljulio commented 1 year ago

@felangel hey sorry I didn't get back to you. I also tried to reproduce it just now but I can't anymore 🤔

I'll let you know if I find something though. Thanks!