getUserByID method
- int userID
Retrieves a User by their ID.
userID: The ID of the user to be fetched.
Returns the User if found, otherwise returns null.
Implementation
Future<User?> getUserByID(int userID) async {
await _databaseWrapper.ensureDBIsInitialized();
final List<Map> maps = await _databaseWrapper.database.query(
'users',
columns: ['ID', 'name', 'hashedPassword'],
where: 'ID = ?',
whereArgs: [userID],
);
if (maps.isNotEmpty) {
return User.fromMap(maps.first);
} else {
return null;
}
}