I'm implementing a search functionality in the app. I'm using firebase where clause to filter the data
the filtered data appears for a second and it then disappeared immediately
here is my code
String searchName = "";
TextFormField(
onChanged: (value){
setState((){
searchName = value;
});
},
decoration: InputDecoration(
hintText: 'SEARCH',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(25.0),
borderSide: BorderSide.none
)
),
),
StreamBuilder(
stream: searchName != "" ? FirebaseFirestore.instance.collectionGroup('user_offers').where("fieldName", isEqualTo: searchName).snapshots() : FirebaseFirestore.instance.collectionGroup('user_offers').snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) {
if(snapshot.hasData){
return ListView.builder() // returning a list
}
return const Center(child: CircularProgressIndicator(color: Colors.white));
},
),
What am I doing wrong? The data appears for a second and it then disappears instantly