Reputation: 1280
I want to create a simple bloc with freezed package. This is my bloc:
import 'package:bloc/bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:presentation/presentation_index.dart';
part 'auth_bloc_event.dart';
part 'auth_bloc_state.dart';
class AuthBlocBloc extends Bloc<AuthEvent, AuthState> {
final SignUpBuyerUseCase signUpBuyerUseCase;
AuthBlocBloc(this.signUpBuyerUseCase) : super(AuthState.initial());
@override
Stream<AuthState> mapEventToState(
AuthEvent event,
) async* {
yield* event.map();
}
}
and my event class :
part of 'auth_bloc.dart';
@freezed
abstract class AuthEvent with _$AuthEvent {
const factory AuthEvent.login(String username, String password) = Login;
const factory AuthEvent.signUpBuyer(BuyerEntity entity) = SignUpBuyer;
}
and state class :
part of 'auth_bloc.dart';
@freezed
abstract class AuthState with _$AuthState {
const factory AuthState.initial() = InitialAuthState;
const factory AuthState.signUpBuyerFail(String error) = SignUpBuyerFail;
const factory AuthState.signUpBuyerSuccess() = SignUpBuyerSuccess;
const factory AuthState.signUpBuyerLoading() = SignUpBuyerLoading;
}
The problem is that when i try to run
flutter pub run build_runner watch --deleteonflicting-outputs
Nothing happens and no classes are generated
Upvotes: 6
Views: 3859
Reputation: 273
In the bloc, you should try to include the freezed file.
part 'auth_bloc_event.dart';
part 'auth_bloc_state.dart';
part 'auth_bloc.freezed.dart';
Upvotes: 2