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