When this widget is called, its stuck on loading animation, and when hot reloaded, it shows the transactions `

class TransactionList extends StatefulWidget {
  final int groupIndex;
  final String groupUid;

  const TransactionList(
      {super.key, required this.groupIndex, required this.groupUid});

  @override
  State<TransactionList> createState() => _TransactionListState();
}

class _TransactionListState extends State<TransactionList> {
  @override
  Widget build(BuildContext context) {
    final groupTransaction = Provider.of<DocumentSnapshot?>(context);

    if (groupTransaction == null) return const Loading();
    return transactionItemsBuilder(groupTransaction);

  }`

edit: this is firebase instance created,

class DatabaseServices {
  final String? uid;

  DatabaseServices({this.uid});

  final CollectionReference groupCollection =
      FirebaseFirestore.instance.collection('groups');

Stream<DocumentSnapshot> get transactions {
    return groupCollection.doc(uid).snapshots();
  }
}

and this is my stream provider

StreamProvider<DocumentSnapshot?>.value(
              initialData: null,
              value: DatabaseServices(uid: widget.item[widget.index].id)
                  .transactions,
              child: TransactionList(
                  groupIndex: widget.index,
                  groupUid: widget.item[widget.index].reference.id),
            ),


Solution 1: Ebin Chandy

Solved this by providing initial data to the stream provider. The data was obtained earlier.