claude refactor
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import 'account_event.dart';
|
||||
import 'account_state.dart';
|
||||
|
||||
class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
AccountBloc() : super(const AccountState()) {
|
||||
on<AccountStatusChanged>((event, emit) => emit(state.copyWith(status: event.status)));
|
||||
}
|
||||
|
||||
void setStatus(AccountStatus status) => add(AccountStatusChanged(status));
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'account_state.dart';
|
||||
|
||||
sealed class AccountEvent {
|
||||
const AccountEvent();
|
||||
}
|
||||
|
||||
class AccountStatusChanged extends AccountEvent {
|
||||
final AccountStatus status;
|
||||
const AccountStatusChanged(this.status);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
enum AccountStatus { undefined, loggedIn, loggedOut }
|
||||
|
||||
class AccountState {
|
||||
final AccountStatus status;
|
||||
const AccountState({this.status = AccountStatus.undefined});
|
||||
|
||||
AccountState copyWith({AccountStatus? status}) => AccountState(status: status ?? this.status);
|
||||
}
|
||||
Reference in New Issue
Block a user