booleanbites / houzi-support

Support forum repo for issues & bugs reported for Houzi Flutter App.
4 stars 0 forks source link

Sort by price doesn’t work in the filter #40

Closed idesigntrends closed 1 year ago

idesigntrends commented 1 year ago

Hi, The sort by price doesn’t work in the filter. Please help.

Screenshot 2023-02-28 082454

AdilSoomro commented 1 year ago

Hello, can we know the website address?

Hassan6197 commented 1 year ago

Hello @idesigntrends, To fix this error, go to packages/houzi_package/lib/pages/search_result.dart file, on line 1747 replace code in the if (_currentPropertyListSortValue == 2) condition with the following code:

if (_currentPropertyListSortValue == 2) {
  propertyList.sort((a, b) {
       String aPriceStr = a.propertyInfo.price.isNotEmpty ? a.propertyInfo.price : "0";
       int aPrice = int.tryParse(aPriceStr.replaceAll(RegExp(r'[^\d]+'), '')) ?? 0;

       String bPriceStr = b.propertyInfo.price.isNotEmpty ? b.propertyInfo.price : "0";
       int bPrice = int.tryParse(bPriceStr.replaceAll(RegExp(r'[^\d]+'), '')) ?? 0;

       return aPrice.compareTo(bPrice);
  });
}

Then go to line 1759 and replace code in the if (_currentPropertyListSortValue == 3) condition with the following code:

if (_currentPropertyListSortValue == 3) {
  propertyList.sort((a, b) {
        String aPriceStr = a.propertyInfo.price.isNotEmpty ? a.propertyInfo.price : "0";
        int aPrice = int.tryParse(aPriceStr.replaceAll(RegExp(r'[^\d]+'), '')) ?? 0;

        String bPriceStr = b.propertyInfo.price.isNotEmpty ? b.propertyInfo.price : "0";
        int bPrice = int.tryParse(bPriceStr.replaceAll(RegExp(r'[^\d]+'), '')) ?? 0;

        return bPrice.compareTo(aPrice);
   });
}
idesigntrends commented 1 year ago

it is fixed, thank you.

AdilSoomro commented 1 year ago

Marking this as closed.