isLoggedIn method

Future<bool> isLoggedIn()

Checks if a user is currently logged in to the Kruzr system.

Returns:

  • bool: true if user is logged in, false otherwise

Usage:

try {
  final loggedIn = await communicator.isLoggedIn();
  if (loggedIn) {
    print('User is logged in');
    // Proceed with authenticated operations
  } else {
    print('User needs to log in');
    // Show login screen
  }
} catch (e) {
  print('Error checking login status: $e');
}

Throws:

  • Future.error("Unable to check login status"): When status check fails

Use Cases:

  • App startup to determine if user needs to log in
  • Before performing authenticated operations
  • Session validation

Implementation

Future<bool> isLoggedIn() async {
  try {
    return await kruzr_comm.isLoggedIn();
  } on PlatformException catch (e) {
    if (kDebugMode) {
      print(e);
      print("PlatformException in isLoggedIn");
    }
    return Future.error("Unable to check login status");
  } on Exception catch (e) {
    if (kDebugMode) {
      print(e);
      print("Exception in isLoggedIn");
    }
    return Future.error("Unable to check login status");
  }
}