add user search to user service

This commit is contained in:
2025-07-09 12:02:33 +02:00
parent 1aa45eccad
commit a47f23c764
2 changed files with 35 additions and 17 deletions

View File

@@ -63,6 +63,26 @@ class MihUserServices {
}
}
Future<List<AppUser>> searchUsers(
String searchText,
BuildContext context,
) async {
var response = await http.get(
Uri.parse("${AppEnviroment.baseApiUrl}/users/search/$searchText"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
);
if (response.statusCode == 200) {
Iterable l = jsonDecode(response.body);
List<AppUser> users =
List<AppUser>.from(l.map((model) => AppUser.fromJson(model)));
return users;
} else {
throw Exception('failed to load users');
}
}
Future<AppUser?> getUserDetails(
String app_id,
BuildContext context,