handleStartUpLogic method

Future handleStartUpLogic()

Implementation

Future handleStartUpLogic() async {
  registerFirebaseServicesToLocator();

  FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;

  final _supabaseService = locator<SupabaseService>();
  await _supabaseService.init();

  final DynamicLinkService _dynamicLinkService =
      locator<DynamicLinkService>();
  await _dynamicLinkService.handleDynamicLinks();

  // Register for push notifications
  final PushNotificationService _pushNotificationService =
      locator<PushNotificationService>();
  await _pushNotificationService.init();

  final RemoteConfigService _remoteConfigService =
      locator<RemoteConfigService>();
  await _remoteConfigService.init();

  final SharedPreferencesService _sharedPreferencesService =
      locator<SharedPreferencesService>();
  await _sharedPreferencesService.init();

  var currentUser = await _authenticationService.fetchUser();
  // _navigationService.navigateTo(
  //     currentUser != null ? Routes.home : Routes.intro,
  //     clearHistory: true);
  // var currentSession = _supabaseService.client.auth.currentSession;

  // TODO Check if user has profile and navigate accordingly, probably share this logic as well
  _navigationService.navigateTo(
      currentUser == null
          ? Routes.intro
          : currentUser.hasProfile
              ? Routes.home
              : Routes.profileSetup,
      clearHistory: true);
}