Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
137 views
in Technique[技术] by (71.8m points)

How to search with space In Flutter Firebase

I Want to Search from by firebase database , But When space in between a name then it does not works at all. So what can i do now.. it works before space is given....

Code:

stream: (searchString==null || searchString.trim()=='')? 
      Firestore.instance.collection('ebook').snapshots() : Firestore.instance.collection('ebook')
          .where('searchIndex',arrayContains: searchString)
          //.where('organization',isEqualTo: searchString )
          .snapshots(),

Here is my Firebase Database

question from:https://stackoverflow.com/questions/65931109/how-to-search-with-space-in-flutter-firebase

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try adding the following:

.where("searchIndex", isGreaterThanOrEqualTo: searchString)  //String comparison
.where('searchIndex', isLessThan: searchString + 'z') //Shows all results until the letter ends with a Z, so this should include spacebar

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...