I have a BloC through which I receive data. But I ran into the problem that there are no different states so that I can display the loading indicator and handle errors if there are any. Can you tell me how can I modify this BloC class to have different states MyCarsLoading, MyCarLoaded so that I can display the loading indicator in the appropriate state?
bloc
class MycarsCubit extends Cubit<MycarsState> {
MycarsCubit()
: super(MycarsInitial(
number: '',
type: '',
));
String number = '';
String type = '';
void clear() {
number = '';
type = '';
}
void change({
required String numberText,
required String typeText,
}) {
number = numberText;
type = typeText;
emit(MycarsInitial(
number: number,
type: type,
));
}
}
state
abstract class MycarsState {}
class MycarsInitial extends MycarsState {
String number;
String type;
MycarsInitial({
required this.number,
required this.type,
});
}