Skip to content
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

[Proposal] Global Stringify #68

Closed
felangel opened this issue May 29, 2020 · 7 comments · Fixed by #69
Closed

[Proposal] Global Stringify #68

felangel opened this issue May 29, 2020 · 7 comments · Fixed by #69
Assignees
Labels
enhancement New feature or request feedback wanted Additional feedback is requested

Comments

@felangel
Copy link
Owner

felangel commented May 29, 2020

Is your feature request related to a problem? Please describe.
It would be nice to have a way to globally configure stringify for all Equatable instances. The proposal includes a breaking change to refactor stringify from a bool to an enum in order to be able to support a "default" (normal) setting in addition to an "enabled" (always) and "disabled" (never) setting.

Describe the solution you'd like

class Credentials extends Equatable {
  final String username;
  final String password;

  const Credentials({this.username, this.password});

  @override
  List<Object> get props => [username, password];
}

// override stringify for all Equatable instances
EquatableConfig.stringify = true;

If stringify is overridden for an individual Equatable it will take precedence over the EquatableConfig value.

Addresses #60 and #65

@felangel felangel added enhancement New feature or request feedback wanted Additional feedback is requested labels May 29, 2020
@felangel felangel self-assigned this May 29, 2020
@felangel felangel pinned this issue May 29, 2020
@zepfietje
Copy link

@felangel could you elaborate on the behavior of the "default" (normal) setting?

@felangel
Copy link
Owner Author

@zepfietje the normal setting will result in just the runtimeType being printed.

@zepfietje
Copy link

@felangel what's the difference between normal and never?

@felangel
Copy link
Owner Author

Normal will defer to the EquatableConfig setting never will never stringify.

@zepfietje
Copy link

So why exactly would we need an enum? Isn't there a way to defer to the EquatableConfig by default and allow the stringify bool to be overridden for an individual Equatable?

@felangel felangel linked a pull request May 29, 2020 that will close this issue
3 tasks
@felangel felangel changed the title [Proposal][BREAKING] Global Stringify [Proposal] Global Stringify May 29, 2020
@felangel
Copy link
Owner Author

@zepfietje good call...I've updated the issue to maintain a bool (which makes this a non-breaking change). The PR is open at #69 👍

@zepfietje
Copy link

@felangel this issue can now be unpinned. 👍

@felangel felangel unpinned this issue May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feedback wanted Additional feedback is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants