70 lines
2.0 KiB
Dart
70 lines
2.0 KiB
Dart
import 'package:discover_module/hive_fun.dart';
|
|
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();
|
|
}
|
|
|
|
// getHCPHive() async {
|
|
// final jsondata = await apicall.getallhcpdata();
|
|
|
|
// _list = jsondata;
|
|
|
|
// notifyListeners();
|
|
// }
|
|
|
|
List searchHCP(String query) {
|
|
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();
|
|
print("JsonIssList: $_list");
|
|
print("queryIssList: $query");
|
|
|
|
return _list
|
|
.where((hcp) =>
|
|
hcp['name'].toLowerCase().contains(query.toLowerCase()) ||
|
|
// (hcp['speciality'].toLowerCase().contains(query.toLowerCase()) ??
|
|
// hcp['spl'].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();
|
|
}
|
|
}
|
|
|
|
getHCPProviderHive() async {
|
|
final jsondata = await HiveFunctions.gethcpdata();
|
|
print("JsonDtaa: ${jsondata}");
|
|
|
|
_list = jsondata;
|
|
print("JsonDtaaList: $_list");
|
|
|
|
notifyListeners();
|
|
//print("Get_hcp_dataaaL ${HiveFunctions.gethcpdata()}");
|
|
}
|
|
}
|