getStore method
dynamic
getStore({})
Implementation
getStore({
required String? delivMethod,
required int? currentBranchId,
int? productID,
int? skuID,
String? skuCode,
required bool initial,
required List<StoreListRequest> products,
}) async {
if (!isLoading) {
isLoading = true;
update();
}
if (initial) {
final defaultLat = double.tryParse(currentLat ?? "");
final defaultLong = double.tryParse(currentLong ?? "");
if (defaultLat != null && defaultLong != null) {
location = LatLong(lat: defaultLat, long: defaultLong);
}
}
final deviceId = await deviceInfoUtils.getDeviceId();
final result = await storeService.getStore2(
deviceId: deviceId,
latitude: location.lat,
longitude: location.long,
deliveryType: delivMethod ?? '',
products: products,
);
result.fold(
(failure) {
onError?.call(failure.message);
},
(data) {
storeList = List.from(data);
},
);
final currentStoreIndex = storeList.indexWhere(
(element) => element.storeId == currentBranchId,
);
if (!currentStoreIndex.isNegative) {
storeList.removeAt(currentStoreIndex);
}
searchList = List.from(storeList);
isLoading = false;
update();
}