ensureUserID method
- User user
Ensures that a User object has a valid ID.
If the User object has no ID set, this method attempts to find the user by their username
and assigns the ID.
user: TheUserobject that needs an ID.
Returns the updated User object with a valid ID.
Implementation
Future<User> ensureUserID(User user) async {
if (user.ID == 0) {
User? userByName = await getUserByName(user.userName);
return userByName!;
} else {
return user;
}
}