DiscoverModule/lib/provider_class/hcp _provider.dart

45 lines
1.3 KiB
Dart
Raw Normal View History

2024-06-27 08:38:43 +00:00
import 'package:discover_module/service.dart/service.dart';
import 'package:flutter/foundation.dart';
class hcpProvider extends ChangeNotifier {
final apicall = Callapi();
List _list = [];
List get list => _list;
getHCPProvider() async {
final jsondata = await apicall.getallhcpdata();
_list = jsondata;
notifyListeners();
}
2024-07-19 08:45:14 +00:00
2024-08-19 08:44:44 +00:00
List searchHCP(String query) {
2024-07-19 08:45:14 +00:00
if (query.isEmpty) {
return List.from(_list); // Return full list if query is empty
} else {
// return _list
// .where(
// (hcp) => hcp['name'].toLowerCase().contains(query.toLowerCase()))
// .toList();
return _list
.where((hcp) =>
hcp['name'].toLowerCase().contains(query.toLowerCase()) ||
hcp['speciality'].toLowerCase().contains(query.toLowerCase()) ||
hcp['addr'].toLowerCase().contains(query.toLowerCase()))
.toList();
// return _list.where((hcp) {
// // Perform multiple checks using logical AND (&&)
// return hcp['name'].toLowerCase().contains(query.toLowerCase()) &&
// hcp['speciality'].toLowerCase().contains(query.toLowerCase()) &&
// hcp['addr'].toLowerCase().contains(query.toLowerCase());
// // Add more conditions as needed
// }).toList();
}
}
2024-06-27 08:38:43 +00:00
}