1

Hi there I am building a flutter e commerce app. In searching stage I tried to use typeahead plugin but it didn't work at all. What is the best way of instant search in flutter app which has backend in firestore. I want to find all data which has typed pattern. (Like typed = "a", results: "ba", "dca", "ax"....) The plugin is not a must for me, I only want to instantly search products, categories by typing.

I could not return the list to typeahead widget;

getSuggestion(pattern){
    documentList = (await Firestore.instance
            .collection("cases")
            .document(await firestoreProvider.getUid())
            .collection(caseCategory)
            .where("caseNumber", isGreaterThanOrEqualTo: query)
            .getDocuments())
            .documents;
return documentList;
}

Widget ;

TypeAheadFormField(
          textFieldConfiguration: TextFieldConfiguration(
            controller: this._typeAheadController,
            decoration: InputDecoration(
              labelText: 'City'
            )
          ),          
          suggestionsCallback: (pattern) {

            return getSuggestions(pattern);
          },
          itemBuilder: (context, suggestion) {
            return ListTile(
              title: Text(suggestion),
            );
       ......
Muhtar
  • 1,506
  • 1
  • 8
  • 33
  • The search type, where the search term can occur anywhere in the data, is not supported by Firestore. You'll want to look at implementing an additional solution to allow such searches, such as https://firebase.google.com/docs/firestore/solutions/search – Frank van Puffelen May 09 '21 at 14:41

0 Answers0