Describe the bug
After update to 1.0.0, the dispatch() function is not defined.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I am heavy bloc user. My flutter app contain around 7 blocs and it works fine until today. After I update to 1.0.0, all of my dispatch() function got method is undefined
error.
Screenshots
If applicable, add screenshots to help explain your problem.
*Logs *
error • The method 'dispatch' isn't defined for the class 'MainBloc' • lib/Profile/profile.dart:107:29 • undefined_method
error • The method 'dispatch' isn't defined for the class 'AuthenticationBloc' • lib/Profile/profile.dart:159:48 • undefined_method
Paste the output of running flutter doctor -v
here.
Additional context
I am using StreamSubscription too and its Bloc.state.listen() too got Method is undefined
error.
Hi @sooonism👋
Thanks for opening an issue!
There were core api changes introduced into 1.0.0:
bloc.state.listen -> bloc.listen
bloc.currentState -> bloc.state
bloc.dispatch -> bloc.add
bloc.dispose -> bloc.close
Check out https://link.medium.com/qnfMcEcW00 for more details.
Hope that helps 👍
Got the same error:
Compiler message:
lib/blocs/login/login_bloc.dart:54:30: Error: The method 'dispatch' isn't defined for the class 'AuthenticationBloc'.
- 'AuthenticationBloc' is from 'package:tascout_app/blocs/authentication/authentication_bloc.dart' ('lib/blocs/authentication/authentication_bloc.dart').
Try correcting the name to the name of an existing method, or defining a method named 'dispatch'.
authenticationBloc.dispatch( LoggedIn(token: user.token));
^^^^^^^^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
Failed to build bundle.
Hi @sooonism👋
Thanks for opening an issue!There were core api changes introduced into 1.0.0:
bloc.state.listen -> bloc.listen
bloc.currentState -> bloc.state
bloc.dispatch -> bloc.add
bloc.dispose -> bloc.closeCheck out https://link.medium.com/qnfMcEcW00 for more details.
Hope that helps 👍
Okay, u have changed with add
:clap:
Most helpful comment
Hi @sooonism👋
Thanks for opening an issue!
There were core api changes introduced into 1.0.0:
bloc.state.listen -> bloc.listen
bloc.currentState -> bloc.state
bloc.dispatch -> bloc.add
bloc.dispose -> bloc.close
Check out https://link.medium.com/qnfMcEcW00 for more details.
Hope that helps 👍