0

I have a search input to look up for my Firebase products. At the moment it is only working if the Capital case or lower case in both products and search value are matched. It also work if I type only 1 character. But I would like to improve it.

For example:

  • if the user does't write exactly the name,
  • or if the the products contains 2 words and user start to type the second word

How can i achieve that?

Container(
      height: MediaQuery.of(context).size.height*0.8,
      child: FutureBuilder<QuerySnapshot>(
          future: _services.userRef.doc(_services.getUserID()).collection('Categories')
              .doc(widget.catID).collection('products').orderBy('name')
          .startAt([_searchValue]).endAt(['$_searchValue\uf8ff']).get(),
          builder: (context, snapshot ){
            if (!snapshot.hasData )
              return Center(child: CircularProgressIndicator());{
              final document = snapshot.data?.docs;
              return ListView.builder(shrinkWrap: true,
                  itemCount: document?.length,
                  itemBuilder: (context, index) {
                    return Center(
                      child: Column(
                        children: [
                          Padding(
                            padding: const EdgeInsets.only(left: 8.0),
                            child: ListTile( title: Text(document![index]['name']),
                              onTap: () {
Giovanni
  • 512
  • 2
  • 6
  • 23
  • Cloud Firestore does not have full-text search capabilities such as those you describe. If those are required for your use-case, consider using another solution such as those shown here: https://firebase.google.com/docs/firestore/solutions/search – Frank van Puffelen Jan 10 '23 at 14:19

0 Answers0