-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement toString feature #45
Conversation
Codecov Report
@@ Coverage Diff @@
## master #45 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 3 3
Lines 45 45
=====================================
Hits 45 45
Continue to review full report at Codecov.
|
Would it be possible to provide also the names for the props to make the |
We do not have the name of the props. We could do a workaround and provide these labels if we see it necessary. |
Hey @nfdz! Sorry for not having taken a look at this PR. I will review it shortly 👍 |
I would love to see the prop names as well. Maybe something like this mixin NamedProps on Equatable {
@override
get props => this.namedProps.values.toList();
Map<String, Object> get namedProps;
@override
toString() => '$runtimeType$namedProps';
} Usage class User extends Equatable with NamedProps {
final String name;
final int age;
@override
get namedProps => {'name': name, 'age': age};
User(this.name, this.age);
} print(User('Foo', 24)); // User{name: Foo, age: 24} |
@felangel Thank you very much for the feedback. I have implemented all the suggestions. About this:
My first implementation was with this check. However, I saw that the I rewrite the code checking nulls, the tests and also fix the |
@felangel do you have thoughts about this? Maybe we should study this in another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thanks so much for the contribution and sorry for the delayed PR review!
Yeah I'd discuss that in a separate issue. I feel like at that point it's easier to just override toString manually haha. Would love to hear what everyone else thinks. |
No worries! Glad to help the project |
Status
READY
Breaking Changes
NO
Description
I implemented the
toString
method feature using the props.I think it is a very useful feature for testing and debugging that most of developers that use this library would like to use. It could be able to do this through an own subclass of equatable or another library but I think that it is overkill for this small feature. This library override already that method and there is no impact implementing this.
Related PRs
No related PRs.
Todos
There is no TODOs
Impact to Remaining Code Base
This new feature will not have impact in the code base, functionality or performance.
It is disabled by default and does not force the user to do changes.