( Flutter Bloc ) doesn't conform to the bound 'StateStreamable<state>' of the type parameter 'B' [closed]
Asked Answered
D

5

7

why am i getting the error? I couldn't find the reason. I'll be happy if you can help me.

error screen

You can check my issue on github

Dubious answered 11/4, 2022 at 12:25 Comment(2)
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.Rumph
Please don’t post images of code, error messages, or other textual data.Stump
D
12

hello i solved the problem. The problem was giving an error because there were 2 classes with the same name, so my StatefulWidget class name was the same as my block state class name :) It was fixed when I changed the name of my block state class.

enter image description here enter image description here

Dubious answered 13/4, 2022 at 10:44 Comment(0)
V
2

You can use same name for StatefulWidget state and use again that name in block or state please dont repeat same name that's wht that errors come

Vaporish answered 10/5, 2022 at 10:25 Comment(0)
C
1

this happens when

  1. You have two classes with the same name
  2. You add the bloc instead of the event

ex:


class CounterBloc extends Bloc<CounterBloc, CounterState> {
  CounterBloc() : super(const InitialState()) {
    on<IncrementEvent>((event, emit) {
      emit(IncrementedCounterState());
    });
    on<IncrementEvent>((event, emit) {
      emit(DecrementedCounterState());
    });
  }
}

I should pass the Event not the bloc in the Bloc<CounterBloc,CounterState> and it should be Bloc<CounterEvent,CounterState>

  1. I will update it with more.
Cindiecindra answered 5/12, 2022 at 7:52 Comment(0)
H
1

If the following primary cause for this issue :

there were 2 classes with the same name

is not the solution , or you have already fixed it and still having the problem,

Simply run the flutter clean and flutter pub get command to fix it.

Holey answered 9/3, 2023 at 5:52 Comment(0)
C
-1

Apart from other solutions also check if you have given type of bloc

class NewsBloc extends Bloc<NewsEvent, NewsState>

if you haven't given <NewsEvent, NewsState> it will give same error.

Checkerwork answered 29/3 at 7:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.