why am i getting the error? I couldn't find the reason. I'll be happy if you can help me.
Asked
Active
Viewed 6,012 times
6
-
1Please 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. – Community Apr 11 '22 at 12:26
4 Answers
6
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.

Serkan Ağca
- 155
- 1
- 6
0
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

Nikhil Kadam
- 109
- 4
0
this happens when
- You have two classes with the same name
- 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>
- I will update it with more.

Abdelrahman M. Elmarakby
- 509
- 7
- 23
0
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.

Akshay Chopra
- 1,035
- 14
- 10