-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add extension on BuildContext #608
Comments
Hey @timrijckaert 👋 I think this is a great idea and there's a lot of potential to improve the
Thoughts? |
This feature is for sure something we would love to use, but I would wait for Flutter first, how they use Extensions so we can align to the API etc. Also, because Flutter Bloc uses |
I agree with all of the above. :) |
Extensions would remove quite a bit of boilerplate so I'm all for it. 👍 |
This would be neat indeed. We're currently using a super simple extension: extension BlocExtension on BuildContext {
T bloc<T extends Bloc>() {
return BlocProvider.of<T>(this);
}
} Though it may or may not be too simple |
@arnemolland It saves a bit of boilerplate, so it's probably fine. 🙂 |
Added the extensions in #816 and published in v3.2.0 of flutter_bloc 🎉 |
Similar to the proposal on the
Provider
package.Are we down for some extension functions to easily get a
Bloc
and aRepository
?The text was updated successfully, but these errors were encountered: