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

Provider Extensions #840

Closed
wants to merge 2 commits into from
Closed

Provider Extensions #840

wants to merge 2 commits into from

Conversation

onatcipli
Copy link

Provider Extensions Update

Hey @rrousselGit, first of all thank you for the great packages that makes flutter devs live easier 😊

This PR adds the Provider Extensions to the Widget class. These extensions have been introduced as an alternative syntactic sugar for providing providers. While they offer a streamlined approach that can reduce boilerplate in certain scenarios, they're intended to complement existing methods rather than replace them, thereby giving developers more flexibility in how they structure their code.

Additions:

What I have added;

ProviderExtension

provideProvider: Equivalent for Provider.
provideProviderValue: Equivalent for Provider.value.

MultiProviderExtension:

provideMultiProvider: Equivalent for MultiProvider.

ChangeNotifierProviderExtension:

provideChangeNotifierProvider: Equivalent for ChangeNotifierProvider.
provideChangeNotifierProviderValue: Equivalent for ChangeNotifierProvider.value.

Example:

Traditional Provider:

Provider<MyObject>(
  create: (_) => MyObject(),
  child: MyWidget(),
);

Using ProviderExtension:

MyWidget().provideProvider(
  create: (_) => MyObject(),
);

Feedback is welcome. Please review the changes and share any suggestions or concerns.

Thank you,
Onat Cipli

@rrousselGit
Copy link
Owner

Hello!

While I very much appreciate your desire to improve Provider, this is unlikely to be something that can land as it is.

This would have to be discussed in an issue first and prove that this is what people want. As it is, such syntax would most likely be controversial due to being at odds with Flutter

The first step before making a PR is to raise an issue to discuss such changes.

For now, I will close this PR. I invite you to raise an issue explaining why we would need this. And if this can get lots of people behind, then we can do it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants