Flutter bloc – Show snackbar on state change


I am trying to log in with Google. When googleSignInAccount I yield new state with PlatformExecption. Now, How can I access that value in order to do some changes.

    final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();

    if(googleSignInAccount == null){
     yield GoogleLoginErrorState(error: PlatformException(code: 'user-cancel'));

my state.dart

class GoogleLoginErrorState extends GoogleLoginState {
  final PlatformException error;

  List<Object> get props => [error];

my BlocBuilder

if (state == GoogleLoginErrorState()) {



In the bloc builder,

if (state is GoogleLoginErrorState) {


This checks if the state data type is GoogleLoginErrorState

And use the state


Answered By – NirmalCode

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *