The following NoSuchMethodError was thrown building StreamBuilder<QuerySnapshot>

1,111

The error indicates that snapshot returns null, make sure that the query is correct, It is likely that this part of your query is not correct document('OrRPMJJyPCThMYMi0mUl').

Share:
1,111
SOS video
Author by

SOS video

Updated on December 25, 2022

Comments

  • SOS video
    SOS video over 1 year

    I tried to implement a Streambuilder to my application, but I get an error when I try my code. This is the error I get:

    The following NoSuchMethodError was thrown building StreamBuilder(dirty, state: _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot>#be008):
    The getter 'documents' was called on null.
    Receiver: null
    Tried calling: documents

    And this is the code I tried:

     @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('Test'),
          ),
          body: StreamBuilder(
            stream: Firestore.instance
                .collection('test')
                .document('OrRPMJJyPCThMYMi0mUl')
                .collection('test')
                .snapshots(),
            builder: (context, snapshot) {
              return ListView.builder(
                itemCount: snapshot.data.documents.length,
                itemBuilder: (context, index) {
                  DocumentSnapshot reservation = snapshot.data.documents[index];
                  return ListTile(
                    title: Text(test['name']),
                  );
                },
              );
            },
          ),
        );