Filter with Algolia | Custom Code | Actions

Hi everyone,

Sorry to bother you if the questions I'll ask are to obvious, I'm learning.

I'm creating an app in which I need a filter like the one shown here https://www.youtube.com/watch?v=I_W2JlGsNOw

I was able to complete the first part, alog with search feature, howevere I've created the filter component and it's not working.

I believe one of the issues could be related to the "algoliaQuery" Code, I'm missing the last part. "final responseHits".

// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:algoliasearch/algoliasearch.dart';

Future<dynamic> algoliaQuery(
  String? query,
  List<String> facets,
  int? propertyBaths,
  int? propertyRooms,
  bool? dogFriendly,
) async {
  final client = SearchClient(
    appId: 'XMPO831NOS',
    apiKey: '58b14fa64ac1fa0fbfc9f6d06d4b6643',
  );

  final queryHits = SearchForHits(
      indexName: 'properties',
      query: '$query',
      facetFilters: [
        facets
      ],
      numericFilters: [
        'propertyBaths >= $propertyBaths',
        'propertyRooms >= $propertyRooms'
      ]);

  final responseHits = await client.searchIndex();

  return responseHits.toJson();
}

The other issue I believe I could have, is related to the Custom Actions, that were not shown on the video, and I'm learning so I don't know if I'm doing them right, maybe do you have other material, video, with a similar applicability I could review to learn and verify if I'm doing it right?

Thanks in advance,

4
4 replies