4xMafole
4xMafole

Reputation: 477

Stream builder returns null on released flutter app using firestore

StreamBuilder widget works well on debug mode but on release mode returns null. I had tried several solutions found here, but none worked. So maybe I am missing something in my code. Here are my source codes.

store_screen.dart

StreamBuilder<List<StoreItem>>(
  initialData: [],
  stream: widget.bloc.getStores(),
  builder: (context, querySnapshot) {
    if (querySnapshot.connectionState == ConnectionState.active) {
      List<StoreItem> stores = querySnapshot.data!;
      ....
    } else if (querySnapshot.hasError) {
      print(querySnapshot.toString());
      ....
    } else {
      ....
      return Center(
        child: CircularProgressIndicator(),
      );
    }
  },
),

store_bloc.dart

Stream<List<StoreItem>> getStores() {
  final snapshot = database.getDataFromCollection('owner');

  return snapshot.map((event) => event.docs
      .map((e) => StoreItem.fromMap(e.data() as Map<String, dynamic>))
      .toList());
}

Upvotes: 1

Views: 93

Answers (1)

Jakhongir Anasov
Jakhongir Anasov

Reputation: 1120

If it works perfectly on debug mode, but failing only on release version, then it can be because of you didn’t add app hash code on firebase config. Also I suggest to check privacy rules of database and make it properly for production.

Upvotes: 0

Related Questions