freezed
freezed copied to clipboard
Less verbose toString() method for sealed classes
Take the following class.
@freezed
abstract class DataEvent with _$DataEvent {
factory DataEvent.versionNameRefreshed(String versionName) =
VersionNameRefreshed;
factory DataEvent.userRefreshed({@required User user}) = UserRefreshed;
factory DataEvent.signedOut() = SignedOut;
}
One of the generated toString() method looks like the following.
@override
String toString() {
return 'DataEvent.userRefreshed(user: $user)';
}
I think that is is better if the toString() method would return 'UserRefreshed(user: $user)'. That is, use the name on the right hand instead of the entire factory name.
On the contrary, if UserRefreshed was a private class i.e. _ UserRefreshed, then I'd prefer keeping the factory name.
I have no plan to implement this.