Hello,
I am using these versions for quite some time now
Seeing errors all over the place when I change the version to the latest.
Whats is the best way to upgrade?
Thanks,
Chethan
I would recommend reading the change log file here :+1:
https://github.com/felangel/bloc/blob/master/packages/bloc/CHANGELOG.md
I just upgraded myself so you'll have to do some search and replace. Ie change currentstate to state and dispose to close etc.
I have also simply managed to upgrade our codebase which is huge codebase and uses flutter_bloc /bloc quite heavily. most important is what @lingster said.
You can check this article by @felangel https://medium.com/flutter-community/bloc-library-v1-0-0-is-here-1f64bd6d3518
technically:
in your Bloc
from
@override
void dispose() {
// Your clean up codes
super.dispose();
}
to
@override
void close() {
// Your clean up codes
super.close();
}
and in bloc again
from
currentState
//or
state
when you need to manipulate your state by add/dispatch an event
from
BlocProvider.of<AnyBloc>(context).dispatch(YourEvent());
to
BlocProvider.of<AnyBloc>(context).add(YourEvent());
or if you are in Bloc itself
from
dispatch(YourEvent());
to
add(YourEvent());
these changes should make your code compatible.
Hey @chethanprabhakar 馃憢
Thanks for opening an issue!
As others have already mentioned you can refer to the changelogs (each package has one e.g bloc) and all of the tutorials and examples in the documentation are always kept up to date. You can also refer the v1.0.0 announcement article or @mhadaily鈥榮 awesome upgrade guide. If you have more specific questions you can also post on gitter.
I would also recommend upgrading equatable independently of the bloc packages so that you limit the amount of changes being made at once.
Hope that helps! 馃憤
thanks @lingster @mhadaily @felangel
Most helpful comment
thanks @lingster @mhadaily @felangel