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

do not lint on ThisNotifier build() => this in generated code #2302

Closed
RandalSchwartz opened this issue Mar 11, 2023 · 3 comments
Closed

do not lint on ThisNotifier build() => this in generated code #2302

RandalSchwartz opened this issue Mar 11, 2023 · 3 comments
Labels
bug Something isn't working linter

Comments

@RandalSchwartz
Copy link

Describe the bug
riverpod_lint is complaining for notifiers that are of their own type, useful when you want to migrate a changenotifier to not
have a separate state instance. This causes ThisProvider build() => this; to be linted, even though everything works.

To Reproduce

@Riverpod(keepAlive: true)
class RubberDuck extends _$RubberDuck {
  @override
  RubberDuck build() => this;
}

and of course the proper imports and build structure.

Expected behavior

The RubberDuck type, a derived class of Notifier, would be accepted and supported as the return type.

@RandalSchwartz RandalSchwartz added bug Something isn't working needs triage labels Mar 11, 2023
@RandalSchwartz RandalSchwartz changed the title support ThisNotifier build() => this in generated code do not lint on ThisNotifier build() => this in generated code Mar 11, 2023
@rrousselGit
Copy link
Owner

Honestly you probably shouldn't do that though

@RandalSchwartz
Copy link
Author

It's the easiest thing possible when porting over a ChangeNotifier to the new framework. There's no specific State type object to work with, and using the Notifier itself shortens the mutate methods. If there's a way to accomplish those easier, I'm listening...

@rrousselGit
Copy link
Owner

Moving all the properties to a mutable state class is decently simple too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linter
Projects
None yet
Development

No branches or pull requests

2 participants