Initial commit: unionflow-mobile-apps
Application Flutter complète (sans build artifacts). Signed-off-by: lions dev Team
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
library notifications_page_wrapper;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import '../../../../core/di/injection.dart';
|
||||
import '../../../../core/utils/logger.dart';
|
||||
import '../../data/repositories/notification_repository.dart';
|
||||
import '../bloc/notifications_bloc.dart';
|
||||
import 'notifications_page.dart';
|
||||
|
||||
/// Wrapper qui fournit le NotificationsBloc à la NotificationsPage
|
||||
class NotificationsPageWrapper extends StatelessWidget {
|
||||
const NotificationsPageWrapper({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<NotificationsBloc>(
|
||||
create: (_) => _getOrCreateNotificationsBloc(),
|
||||
child: const NotificationsPage(),
|
||||
);
|
||||
}
|
||||
|
||||
static NotificationsBloc _getOrCreateNotificationsBloc() {
|
||||
try {
|
||||
if (GetIt.instance.isRegistered<NotificationsBloc>()) {
|
||||
return GetIt.instance<NotificationsBloc>();
|
||||
}
|
||||
} catch (e, st) {
|
||||
AppLogger.error('NotificationsPageWrapper: résolution NotificationsBloc échouée', error: e, stackTrace: st);
|
||||
}
|
||||
final repo = getIt<NotificationRepository>();
|
||||
return NotificationsBloc(repo);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user