flutter_bloc 0.22.1 in flutter

flutter_bloc 0.22.1 in flutter :

flutter bloc new version 0.22.1 error is currentState and dispatch() method is deprecated. This flutter tutorial post is one of easy solution provide.

flutter_bloc 0.22.1 in flutter

currentState solution

currentState to replace: state
state is return the current state of the Bloc.

For example:

if (event is PasswordInput) {
      yield currentState.copyWith(password: event.password);
}

Solution

if (event is PasswordInput) {
      yield state.copyWith(password: event.password);
}

dispatch() solution

dispatch() to replace: add()

Notifies the [Bloc] of a new [Event] which triggers mapEventToState. If close has already been called, any subsequent calls to add will be delegated to the onError method which can be overriden at the [Bloc] as well as the [BlocDelegate] level.

void login(callback) {
    dispatch(Login(callback: callback));
  }

Solution

void login(callback) {
    add(Login(callback: callback));
  }

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in