5

我想用冷冻包创建一个简单的块。这是我的集团:

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();
    
  }
}

和我的活动课:

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;
}

和状态类:

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;
}

问题是当我尝试运行时

flutter pub run build_runner watch --deleteonflicting-outputs

什么都没有发生,也没有生成任何类

4

1 回答 1

1

在 bloc 中,您应该尝试包含冻结的文件。

part 'auth_bloc_event.dart';
part 'auth_bloc_state.dart';
part 'auth_bloc.freezed.dart';
于 2021-01-06T17:29:40.710 回答