Bloc: Clarify README section regarding extensions usage

Created on 14 Feb 2020  路  2Comments  路  Source: felangel/bloc

Hey! I've been using bloc library extensively by now and today I went back to consult README section where I found this snippet:

// with extensions
context.bloc<BlocA>();

// without extensions
BlocProvider.of<BlocA>(context)

I'm using your superb VSCode extension for snippets and bloc scaffolding but I can't figure out how or where context.bloc<BlocA>(); works?

flutter_bloc question

Most helpful comment

Oh, now I see it! Should've looked at the change log and followed on #608, that's a very convenient improvement, thanks a lot for your tireless and fruitful labour. Cheers!

All 2 comments

Hi @nvma 馃憢
Thanks for opening an issue and for the positive feedback!

With flutter_bloc v3.2.0 you can now use the extensions on BuildContext. Just make sure you're using v3.2.0 and that you have import 'package:flutter_bloc/flutter_bloc.dart'; at the top of your file and you should be good to go.

Please let me know if that helps, thanks!

Oh, now I see it! Should've looked at the change log and followed on #608, that's a very convenient improvement, thanks a lot for your tireless and fruitful labour. Cheers!

Was this page helpful?
0 / 5 - 0 ratings