feat: Refactor code structure and optimize performance across multiple modules

This commit is contained in:
Achintha Isuru
2025-11-17 23:29:28 -05:00
parent 831570f2e0
commit a64cbd9edf
1508 changed files with 105319 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import 'package:bloc/bloc.dart';
import 'package:meta/meta.dart';
import '../../../../core/application/di/injectable.dart';
import '../notification_entity.dart';
import '../notification_repository.dart';
part 'notifications_event.dart';
part 'notifications_state.dart';
class NotificationsBloc extends Bloc<NotificationsEvent, NotificationsState> {
NotificationsBloc() : super(NotificationsState()) {
on<NotificationsInitEvent>(_onNotificationsInit);
}
void _onNotificationsInit(NotificationsInitEvent event, emit) async {
var notifications =
await getIt<NotificationsRepository>().fetchNotifications();
emit(state.copyWith(
notifications: notifications,
));
}
}

View File

@@ -0,0 +1,7 @@
part of 'notifications_bloc.dart';
@immutable
sealed class NotificationsEvent {}
class NotificationsInitEvent extends NotificationsEvent {
}

View File

@@ -0,0 +1,20 @@
part of 'notifications_bloc.dart';
@immutable
class NotificationsState {
final bool inLoading;
final List<NotificationEntity> notifications;
NotificationsState({this.inLoading = false, this.notifications = const []});
NotificationsState copyWith({
bool? inLoading,
List<NotificationEntity>? notifications,
}) {
return NotificationsState(
inLoading: inLoading ?? this.inLoading,
notifications: notifications ?? this.notifications,
);
}
}