gpt4 book ai didi

flutter - 如何在 flutter 中使用带有 Bloc 的 Freezed 包?

转载 作者:行者123 更新时间:2023-12-04 03:43:39 24 4
gpt4 key购买 nike

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

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


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

最佳答案

在 bloc 中,您应该尝试包含卡住的文件。

part 'auth_bloc_event.dart';
part 'auth_bloc_state.dart';
part 'auth_bloc.freezed.dart';

关于flutter - 如何在 flutter 中使用带有 Bloc 的 Freezed 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65530114/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com