resolveLandingLocation function
- PreferencesRepository preferencesRepository
Resolves the landing route used after authentication.
Falls back to home if preferences cannot be read so a storage failure does not block app startup or a successful login.
Implementation
Future<String> resolveLandingLocation(
PreferencesRepository preferencesRepository,
) async {
try {
final startWithCourseTable = await preferencesRepository.get(
PrefKey.startWithCourseTable,
);
return switch (startWithCourseTable) {
true => AppRoutes.courseTable,
false => AppRoutes.home,
};
} catch (error) {
debugPrint('Failed to resolve authenticated landing preference: $error');
return AppRoutes.home;
}
}