Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
router_helper.dart
Go to the documentation of this file.
1import 'package:flutter/material.dart';
2import 'package:flutter_bloc/flutter_bloc.dart';
3import '../../features/authentication/presentation/logic/authentication_bloc/authentication_bloc.dart';
4import '../../features/authentication/domain/entities/session_entity.dart';
5
6extension RouterContextExtension on BuildContext {
7 SessionEntity? get session {
8 final authState = read<AuthenticationBloc>().state;
9 return authState is AuthenticatedState ? authState.session : null;
10 }
11
12 T withSession<T>({
13 required T Function(SessionEntity session) authenticated,
14 Widget Function()? unauthenticated,
15 }) {
16 final currentSession = session;
17 if (currentSession != null) {
18 return authenticated(currentSession);
19 }
20 if (unauthenticated != null) {
21 return unauthenticated() as T;
22 }
23 throw Exception('Unauthenticated access');
24 }
25}
final Function(ProposedTimeEntity pickedTimeRange) onPickTimeRange