mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-12 10:38:56 +03:30
Set search my item by api
This commit is contained in:
@@ -43,17 +43,31 @@ class MyItemProvider extends ChangeNotifier {
|
||||
|
||||
void setLoading() {
|
||||
isloading = true;
|
||||
// notifyListeners();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void searchMyItems(String value) {
|
||||
Future<void> searchMyItems(String value) async {
|
||||
myItems = [];
|
||||
searchBoxValue = value;
|
||||
originalMyItems!.forEach((result) {
|
||||
if (result.udi.toString().contains(searchBoxValue)) {
|
||||
myItems!.add(result);
|
||||
}
|
||||
});
|
||||
var response = await http.get(
|
||||
Uri.parse(Url.searchMyItems(value)),
|
||||
headers: {'Authorization': User.token, "Accept": "application/json"},
|
||||
);
|
||||
|
||||
var itemsData = json.decode(response.body);
|
||||
|
||||
for (var item in itemsData['data']) {
|
||||
myItems!.add(
|
||||
MyItemResultObject(
|
||||
name: item['name'],
|
||||
id: item['id'].toString(),
|
||||
size: item['size'].toString(),
|
||||
udi: item['udi'],
|
||||
userName: item['user'] != null ? item['user']['name'] : '',
|
||||
),
|
||||
);
|
||||
}
|
||||
resetLoading();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -136,8 +150,9 @@ class MyItemProvider extends ChangeNotifier {
|
||||
),
|
||||
);
|
||||
}
|
||||
myItems = originalMyItems;
|
||||
pageNumber += 1;
|
||||
searchMyItems('');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Future<void> getHospitalItems() async {
|
||||
|
||||
Reference in New Issue
Block a user