userDetails method
Retrieves detailed information about the currently logged-in user.
Returns:
RegisteredDriver?: User details object, ornullif not available
Usage:
try {
final userInfo = await communicator.userDetails();
if (userInfo != null) {
print('User: ${userInfo.name}');
print('Driver ID: ${userInfo.driverId}');
}
} catch (e) {
print('Failed to get user details: $e');
}
Throws:
Future.error("Unable to get user details"): When retrieval fails
Prerequisites:
- User must be logged in
- Valid session must exist
Implementation
Future<RegisteredDriver?> userDetails() async {
try {
return await kruzr_comm.userDetails();
} on PlatformException catch (e) {
if (kDebugMode) {
print(e);
print("PlatformException in userDetails");
}
return Future.error("Unable to get user details");
} on Exception catch (e) {
if (kDebugMode) {
print(e);
print("Exception in userDetails");
}
return Future.error("Unable to get user details");
}
}