Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
notifications_bloc.dart
Go to the documentation of this file.
1import 'package:bloc/bloc.dart';
2import 'package:equatable/equatable.dart';
3
4import '../../../../core/error/failures.dart';
5import '../../../../core/services/service_locator.dart';
6import '../../domain/entities/notification_entity.dart';
7import '../../domain/usecases/get_notifications_usecase.dart';
8
9part 'notifications_event.dart';
10part 'notifications_state.dart';
11
12class NotificationsBloc extends Bloc<NotificationsEvent, NotificationsState> {
14
15 NotificationsBloc() : super(NotificationsInitial()) {
16 on<LoadNotificationsEvent>(_onLoadNotifications);
17 }
18
21 Emitter<NotificationsState> emit,
22 ) async {
23 emit(NotificationsLoading());
24
25 final result = await getNotificationsUseCase(
26 GetNotificationsParams(
27 userId: event.userId,
28 ),
29 );
30
31 result.fold(
32 (failure) => emit(NotificationsError(failure: failure)),
34 );
35 }
36
37}
sealed class AuthenticationState extends Equatable failure
sealed class CheckInOutEvent extends Equatable userId
Future< void > _onLoadNotifications(LoadNotificationsEvent event, Emitter< NotificationsState > emit,) async
GetNotificationsUseCase({required this.repository})
const LoadNotificationsEvent({required this.userId})
sealed class NotificationsState extends Equatable notifications
const NotificationsLoaded({required this.notifications})
final sl